itsimiro / mi-structure
Structure data type
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.0
Requires (Dev)
- fakerphp/faker: ^1.9.1
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^9.3
README
This package is tries to represent a struct from other languages.
Getting started
class MyStructure extends \Structure\Structure { public int $userId = 1; } $userId = (new MyStructure())->userId; // $userId = 1;
OR
class MyStructure extends \Structure\Structure { #[MapFrom(name: 'user_id')] public int $userId; } $userData = [ 'user_id' => 10 ]; $structure = (new MyStructure($data)); $userId = $structure->userId; // $userId = 10; $userId = $structure->getUserId(); // $userId = 10;
Rules
class MyStructure extends \Structure\Structure { #[VariableRules(length: 5, equals: 'Iron Man')] public string $name = 'Miro'; } $userId = (new MyStructure())->name; // There will be an exception "StructureValidateException"