icanboogie / common
Common helpers and classes for ICanBoogie
Installs: 251 827
Dependents: 13
Suggesters: 1
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=7.1
- ext-mbstring: *
Requires (Dev)
- phpstan/phpstan: ^0.12.92
- phpunit/phpunit: ^7.5|^9.5
This package is auto-updated.
Last update: 2024-11-15 23:35:10 UTC
README
This package provides basic classes and helpers shared by many ICanBoogie packages. It provides offset exceptions, property exceptions, some interfaces, and helpers to transform strings and arrays.
Installation
composer require icanboogie/common
Exceptions
Offset exceptions
The package defines the following exceptions related to array offset:
- OffsetError: Interface for offset errors.
- OffsetNotDefined: Exception thrown when an array offset is not defined.
- OffsetNotReadable: Exception thrown when an array offset is not readable.
- OffsetNotWritable: Exception thrown when an array offset is not writable.
Property exceptions
The following exceptions related to object properties defined by the package:
- PropertyError: Interface for property errors.
- PropertyNotDefined: Exception thrown when a property is not defined.
- PropertyNotReadable: Exception thrown when a property is not readable.
- PropertyNotWritable: Exception thrown when a property is not writable.
<?php use ICanBoogie\PropertyNotDefined; class A { private $id; public function __get(string $property) { if ($property === 'id') { return $this->id; } throw new PropertyNotDefined([ $property, $this ]); } }
Interfaces
The package defines the following interfaces:
- ToArray: Should be implemented by classes whose instances can be converted into arrays.
- ToArrayRecursive: Should be implemented by classes whose instances can be converted into arrays recursively.
<?php use ICanBoogie\ToArray; use ICanBoogie\ToArrayRecursive; class A implements ToArrayRecursive { use ToArrayRecursiveTrait; public function to_array(): array { return (array) $this; } }
Continuous Integration
The project is continuously tested by GitHub actions.
Code of Conduct
This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.
Contributing
See CONTRIBUTING for details.