Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thenlabs/class-builder
Dynamic management of classes, traits and interfaces in PHP.
https://github.com/thenlabs/class-builder
builder builder-pattern php php-builder php-class php-classes php-interface php-library php-traits
Last synced: 9 days ago
JSON representation
Dynamic management of classes, traits and interfaces in PHP.
- Host: GitHub
- URL: https://github.com/thenlabs/class-builder
- Owner: thenlabs
- License: mit
- Created: 2020-02-07T15:46:35.000Z (over 4 years ago)
- Default Branch: 1.0
- Last Pushed: 2022-05-13T22:28:38.000Z (over 2 years ago)
- Last Synced: 2024-09-18T02:22:42.999Z (about 2 months ago)
- Topics: builder, builder-pattern, php, php-builder, php-class, php-classes, php-interface, php-library, php-traits
- Language: PHP
- Homepage: https://github.com/thenlabs/class-builder/blob/1.0/doc/es/index.md
- Size: 181 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- cuban-opensource - ClassBuilder
README
# ClassBuilder
Dynamic management of classes, traits and interfaces in PHP.
>If you like this project gift us a ⭐.
## Documentation.
1. English (Pending)
2. [Español](doc/es/index.md)## Installation.
$ composer require thenlabs/class-builder
>Require PHP >= 7.2
## Example.
The next example shows a way to create dinamically a PHP class using our `ClassBuilder`.
```php
setNamespace('ThenLabs\Demo');$personClass->addProperty('name')->setAccess('protected');
$personClass->addMethod('__construct', function (string $name) {
$this->name = $name;
});$personClass->addMethod('getName', function (): string {
return $this->name;
});$personClass->install();
$andy = new Person('Andy');
$andy->getName() === 'Andy'; // true
$andy instanceof \ThenLabs\Demo\Person; // true
```## Development.
Clone this repository and install the Composer dependencies.
$ composer install
### Running the tests.
All the tests of this project was written with our testing framework [PyramidalTests][pyramidal-tests] wich is based on [PHPUnit][phpunit].
Run tests:
$ composer test
[phpunit]: https://phpunit.de
[pyramidal-tests]: https://github.com/thenlabs/pyramidal-tests