-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathClassWithPropertiesWithSubAttributes.php
More file actions
47 lines (36 loc) · 1.03 KB
/
Copy pathClassWithPropertiesWithSubAttributes.php
File metadata and controls
47 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace Crell\AttributeUtils\Attributes;
use Attribute;
use Crell\AttributeUtils\HasSubAttributes;
use Crell\AttributeUtils\ParseProperties;
#[Attribute(Attribute::TARGET_CLASS)]
class ClassWithPropertiesWithSubAttributes implements ParseProperties, HasSubAttributes
{
public array $properties = [];
public string $c;
public function __construct(
public bool $include = true,
) {}
public function setProperties(array $properties): void
{
$this->properties = $properties;
}
public function includePropertiesByDefault(): bool
{
return $this->include;
}
public function propertyAttribute(): string
{
return ConfigurablePropertyWithSubAttributes::class;
}
public function subAttributes(): array
{
return [ClassSubAttribute::class => 'fromSubAttribute'];
}
public function fromSubAttribute(?ClassSubAttribute $sub): void
{
$sub ??= new ClassSubAttribute();
$this->c = $sub->c;
}
}