ft/attributes

PHP属性如json、日志和属性验证的目录

2.2.2 2023-02-14 02:48 UTC

This package is auto-updated.

Last update: 2024-09-14 06:42:20 UTC


README

PHP属性的目录,用于灵活和可维护的建模。

用于日志、json、属性验证等属性。

属性验证的快速示例

final class MyClass {
    use PropertyValidator;

    #[Email]
    private string $email;

    #[Min(value: 12)]
    private int $age;

    #[Size(min: 1, max: 3)]
    private array $phone_numbers;
}

json的快速示例

class MyClass {
    private int $id = 1;
    #[JsonIgnore]
    private string $ssn = "xxx-xx-xxxx";
}

Json::encode(new MyClass); // { "id" : 1 }

有关完整文档和属性使用方法,请参阅文档wiki