Download the PHP package italix/contracts without Composer
On this page you can find all versions of the php package italix/contracts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download italix/contracts
More information about italix/contracts
Files in italix/contracts
Package contracts
Short Description Shared contracts (interfaces) for Italix libraries - enables seamless integration between italix/orm, italix/forms, and other compatible libraries
License Apache-2.0
Homepage https://github.com/italix-net/contracts
Informations about the package contracts
Italix Contracts
Shared interfaces and foundational classes for Italix libraries, enabling seamless integration between italix/orm, italix/forms, and other compatible libraries.
Installation
Purpose
This package provides the common contracts and building blocks that allow different Italix libraries to work together without tight coupling:
- italix/orm implements these contracts on its
TableandColumnclasses - italix/forms consumes any object implementing these contracts
- Third-party libraries can implement these contracts for compatibility
Contents
Interfaces
| Interface | Description |
|---|---|
TableMeta |
Describes a table/entity with its columns |
ColumnMeta |
Describes a column/field with its type and constraints |
RelationMeta |
Describes a foreign key relationship |
RelationalColumnMeta |
A column that may have FK relations (extends ColumnMeta) |
PolymorphicColumnMeta |
A polymorphic FK column (extends ColumnMeta) |
DelegatedTableMeta |
A table using delegated types pattern (extends TableMeta) |
Classes
| Class | Description |
|---|---|
DataContainer |
Lightweight array-backed data container with array access, iteration, and JSON support |
DataContainer
A general-purpose data container that wraps an associative array and provides both array syntax ($c['key']) and a clean method-based API.
Implements ArrayAccess, Countable, IteratorAggregate, and JsonSerializable.
Quick Start
Getting Values
Extracting Data
Modifying Data
Iteration, Counting, and JSON
Extending DataContainer
DataContainer is designed to be extended. The $data property is protected,
so subclasses can access it directly:
snake_case Convention
All Italix public methods use snake_case. The methods required by PHP's
built-in interfaces (offsetGet, jsonSerialize, getIterator) are
implemented as required, with snake_case aliases provided:
| PHP interface method | snake_case alias |
|---|---|
jsonSerialize() |
json_serialize() |
getIterator() |
get_iterator() |
The ArrayAccess methods (offsetGet, offsetSet, offsetExists, offsetUnset)
don't need aliases because they are called implicitly via array syntax ($c['key']),
not directly. Use get(), set(), has(), and remove() instead.
Complete API Reference
| Method | Returns | Description |
|---|---|---|
__construct(array $data = []) |
Create with optional initial data | |
get($key, $default = null) |
mixed |
Get value by key, with default |
set($key, $value) |
self |
Set a value (chainable) |
has($key) |
bool |
Key exists and is not null |
has_key($key) |
bool |
Key exists, even if null |
remove($key) |
self |
Remove a key (chainable) |
merge(array $data) |
self |
Merge in new data (chainable) |
to_array() |
array |
Get all data as plain array |
only(array $keys) |
array |
Get subset of keys |
except(array $keys) |
array |
Get all data except specified keys |
keys() |
array |
Get all keys |
values() |
array |
Get all values |
is_empty() |
bool |
Check if container has no data |
clear() |
self |
Remove all data (chainable) |
count() |
int |
Number of entries (also works with count()) |
json_serialize() |
array |
Get data for JSON encoding |
get_iterator() |
Traversable |
Get iterator for foreach |
Interfaces
Implementing TableMeta
Implementing ColumnMeta
Using with italix/forms
Hierarchy
Requirements
- PHP 7.4 or higher
License
Apache-2.0