-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathClassWithSubSubAttributeLevelOne.php
More file actions
38 lines (29 loc) · 919 Bytes
/
Copy pathClassWithSubSubAttributeLevelOne.php
File metadata and controls
38 lines (29 loc) · 919 Bytes
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
<?php
declare(strict_types=1);
namespace Crell\AttributeUtils\Attributes;
use Attribute;
use Crell\AttributeUtils\HasSubAttributes;
use function Crell\fp\amap;
use function Crell\fp\prop;
#[Attribute(Attribute::TARGET_CLASS)]
class ClassWithSubSubAttributeLevelOne implements HasSubAttributes
{
public ?ClassWithSubSubAttributeLevelTwo $sub;
public array $d;
public function __construct(public string $b = '') {}
public function subAttributes(): array
{
return [
ClassWithSubSubAttributeLevelTwo::class => 'fromSubAttribute',
ClassWithSubSubAttributeLevelTwoMulti::class => 'fromMultiSubAttributes',
];
}
public function fromSubAttribute(?ClassWithSubSubAttributeLevelTwo $sub): void
{
$this->sub = $sub;
}
public function fromMultiSubAttributes(array $subs): void
{
$this->d = amap(prop('d'))($subs);
}
}