PHPackages                             oihana/php-core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. oihana/php-core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

oihana/php-core
===============

The Oihana PHP Core library

1.0.7(5mo ago)146012MPL-2.0PHPPHP &gt;=8.4CI passing

Since Jul 10Pushed 3mo agoCompare

[ Source](https://github.com/BcommeBois/oihana-php-core)[ Packagist](https://packagist.org/packages/oihana/php-core)[ Docs](https://github.com/BcommeBois/oihana-php-core)[ RSS](/packages/oihana-php-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (12)

Oihana PHP - Core library
=========================

[](#oihana-php---core-library)

[![Oihana Php Core](https://raw.githubusercontent.com/BcommeBois/oihana-php-core/main/.phpdoc/template/assets/images/oihana-php-core-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-core/main/.phpdoc/template/assets/images/oihana-php-core-logo-inline-512x160.png)

A lightweight and modular core library for modern PHP development. Designed for clarity, extensibility, and performance, with a consistent, functional-style API.

[![Latest Version](https://camo.githubusercontent.com/3f4e3c09f1c13609ed78189ab0fce13b00460ba7b21219c7468626d36bf862da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-core)
[![Total Downloads](https://camo.githubusercontent.com/2ef4729bbc3f4d1950cfe4bd3c5a5b1b910c2327dbef819f90d130f735566cc3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-core)
[![License](https://camo.githubusercontent.com/827c420d44e3a90e8ab64210671ccf0d0b2690ead89964ef0492d3b1628b1b70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d636f72652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Table of Contents
-----------------

[](#table-of-contents)

- [✨ Core Packages](#core-packages)
- [📚 Documentation](#documentation)
- [📦️ Installation](#installation)
- [💡 Features](#features)
- [🚀 Quick Start](#quick-start)
- [🧪 Examples](#examples)
- [✅ Running Unit Tests](#running-unit-tests)
- [🤝 Contributing](#contributing)
- [🧾 License](#license)
- [👤 About the author](#about-the-author)

Core Packages
-------------

[](#core-packages)

The library provides a suite of pure, side-effect-free utility functions organized into logical namespaces. Here’s a summary of what each package offers:

NamespaceDescription`oihana\core\accessors`Provides unified functions (`get`, `set`, `has`, `delete`) to safely access and manipulate nested data in both arrays and objects using dot notation.`oihana\core\arrays`A rich suite of utilities for array manipulation, including transformations, access, and structural analysis.`oihana\core\bits`A set of utilities for bit masks manipulation.`oihana\core\callables`A set of utilities for functions and callable definitions.`oihana\core\date`Helpers for date formatting and validation.`oihana\core\documents`Utilities for placeholder resolution and document formatting.`oihana\core\env`Functions to detect the current environment (CLI, Docker, OS) and PHP settings.`oihana\core\json`Helpers for advanced JSON serialization and flag validation.`oihana\core\maths`Functions for smart numeric rounding operations (ceil, floor, round).`oihana\core\numbers`Utilities for handling numbers, such as clamping a value within a specific range.`oihana\core\objects`Lightweight helpers for object manipulation, like compressing and deep-setting values.`oihana\core\options`Provides Enums for configuring function behaviors (e.g., `CompressOption`).`oihana\core\reflections`Provides reflection utilities to inspect functions and their properties.`oihana\core\strings`A comprehensive set of tools for string formatting, case conversion, validation, and generation.`oihana\core` (Utils)General-purpose utilities, such as `normalize()`, `ifNull()`, `isLiteral()` and `toNumber()`.Documentation
-------------

[](#documentation)

Full project documentation is available at: 👉

- Changelog: [CHANGELOG.md](./CHANGELOG.md)
- License: [MPL-2.0](./LICENSE)

Installation
------------

[](#installation)

> **Requires [PHP 8.4+](https://php.net/releases/)**

Install via [Composer](https://getcomposer.org):

```
composer require oihana/php-core
```

Features
--------

[](#features)

The oihana/php-core library provides pure utility functions (no side effects), organized into logical, reusable packages:

### 🧾 Accessors (`oihana\core\accessors`)

[](#-accessors-oihanacoreaccessors)

Unified access for both arrays and objects:

- Read: `getKeyValue()`
- Write: `setKeyValue()`
- Delete: `deleteKeyValue()` (supports wildcards: `*`, `foo.bar.*`)
- Exists: `hasKeyValue()`
- Validation and traversal: `assertDocumentKeyValid()`, `resolveReferencePath()`

### 🔢 Arrays (`oihana\core\arrays`)

[](#-arrays-oihanacorearrays)

Advanced array utilities:

- Access and mutation: `get()`, `set()`, `delete()`, `exists()`
- Transformations: `flatten()`, `tail()`, `unique()`, `shuffle()`, `swap()`, `toArray()`, `stub()`
- Structure detection: `isIndexed()`, `hasIntKeys()`, `hasStringKeys()`

### 📅 Date (`oihana\core\date`)

[](#-date-oihanacoredate)

Date manipulation and validation:

- `formatDateTime()`
- `isDate()`, `isValidTimezone()`
- `now()`

### 📄 Documents (`oihana\core\documents`)

[](#-documents-oihanacoredocuments)

Template and placeholder resolution:

- `formatDocument()`
- `resolvePlaceholders()`

### 💻 Env (`oihana\core\env`)

[](#-env-oihanacoreenv)

Environment detection helpers:

- OS detection: `isLinux()`, `isMac()`, `isWindows()`
- Environment type: `isCli()`, `isWeb()`, `isDocker()`
- PHP info: `phpVersion()`, `isExtensionLoaded()`

### 🧬 JSON (`oihana\core\json`)

[](#-json-oihanacorejson)

Advanced JSON utilities:

- `deepJsonSerialize()`
- `isValidJsonEncodeFlags()`, `isValidJsonDecodeFlags()`

### ➗ Maths (`oihana\core\maths`)

[](#-maths-oihanacoremaths)

Smart numeric rounding helpers:

- `ceilValue()`, `floorValue()`, `roundValue()`
- Geolocation: `haversine()`, `bearing()`

### 🔢 Numbers (`oihana\core\numbers`)

[](#-numbers-oihanacorenumbers)

- Range clamping: `clip()`

### 🧱 Objects (`oihana\core\objects`)

[](#-objects-oihanacoreobjects)

Lightweight object manipulation:

- `compress()` — remove null/empty values
- `set()` — deep set a value in a nested structure
- `toAssociativeArray()`

### ⚙️ Reflections (`oihana\core\reflections`)

[](#️-reflections-oihanacorereflections)

- Function analysis: `getFunctionInfo()`

### ✍️ Strings (`oihana\core\strings`)

[](#️-strings-oihanacorestrings)

String formatting, case conversions, and utilities:

- Case &amp; slug: `camel()`, `snake()`, `kebab()`, `hyphenate()`, `lower()`, `latinize()`
- Format &amp; identifiers: `fastFormat()`, `formatRequestArgs()`, `urlencode()`, `toString()`
- Validation: `isRegexp()`, `luhn()`
- Random generation: `randomKey()`

### 🛠️ Utils (`oihana\core`)

[](#️-utils-oihanacore)

General-purpose helpers:

- `ifNull()` — return a fallback if a value is null
- `isLiteral()` — check if a value is a literal

Quick Start
-----------

[](#quick-start)

Most helpers are loaded via Composer autoload. You can import functions directly using `use function` and call them.

```
