-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathCollectionProxy.php
141 lines (126 loc) · 2.91 KB
/
CollectionProxy.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* @package s9e\TextFormatter
* @copyright Copyright (c) The s9e authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Configurator\Traits;
/**
* Allows an object to act as a proxy for a NormalizedCollection stored in $this->collection
*
* @property \s9e\TextFormatter\Collections\NormalizedCollection $collection
*
* @method mixed add(string $key, mixed $value)
* @method array asConfig()
* @method bool contains(mixed $value)
* @method void delete(string $key)
* @method bool exists(string $key)
* @method mixed get(string $key)
* @method mixed indexOf(mixed $value)
* @method string normalizeKey(string $key)
* @method mixed normalizeValue(mixed $value)
* @method string onDuplicate(string $action)
* @method mixed set(string $key, mixed $value)
*/
trait CollectionProxy
{
/**
* Forward all unknown method calls to $this->collection
*
* @param string $methodName
* @param array $args
* @return mixed
*/
public function __call($methodName, $args)
{
return call_user_func_array([$this->collection, $methodName], $args);
}
//==========================================================================
// ArrayAccess
//==========================================================================
/**
* @param string|integer $offset
* @return bool
*/
public function offsetExists($offset): bool
{
return isset($this->collection[$offset]);
}
/**
* @param string|integer $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->collection[$offset];
}
/**
* @param string|integer $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value): void
{
$this->collection[$offset] = $value;
}
/**
* @param string|integer $offset
* @return void
*/
public function offsetUnset($offset): void
{
unset($this->collection[$offset]);
}
//==========================================================================
// Countable
//==========================================================================
/**
* @return integer
*/
public function count(): int
{
return count($this->collection);
}
//==========================================================================
// Iterator
//==========================================================================
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->collection->current();
}
/**
* @return string|integer
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->collection->key();
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function next()
{
return $this->collection->next();
}
/**
* @return void
*/
public function rewind(): void
{
$this->collection->rewind();
}
/**
* @return boolean
*/
public function valid(): bool
{
return $this->collection->valid();
}
}