itsimiro/mi-structure

Structure data type

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:project

pkg:composer/itsimiro/mi-structure

v1.0.0 2022-06-23 19:38 UTC

This package is auto-updated.

Last update: 2025-09-29 02:44:14 UTC


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"