-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathNames.php
More file actions
61 lines (47 loc) · 1.27 KB
/
Copy pathNames.php
File metadata and controls
61 lines (47 loc) · 1.27 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Crell\AttributeUtils\InterfaceAttributes;
use Attribute;
use Crell\AttributeUtils\HasSubAttributes;
use function Crell\fp\method;
#[Attribute(Attribute::TARGET_CLASS)]
class Names implements HasSubAttributes, \IteratorAggregate, \ArrayAccess, \Countable
{
protected readonly array $names;
public function subAttributes(): array
{
return [Name::class => 'fromNames'];
}
public function fromNames(array $names): void
{
$this->names = $names;
}
public function count(): int
{
return count($this->names);
}
public function nameList(): array
{
return array_map(method('fullName'), $this->names);
}
public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->names);
}
public function offsetExists(mixed $offset): bool
{
return array_key_exists($offset, $this->names);
}
public function offsetGet(mixed $offset): Alias
{
return $this->names[$offset];
}
public function offsetSet(mixed $offset, mixed $value): void
{
throw new \InvalidArgumentException();
}
public function offsetUnset(mixed $offset): void
{
throw new \InvalidArgumentException();
}
}