@@ -38,6 +38,5 @@ |
||
38 | 38 | * Class InvalidOperationException |
39 | 39 | * @package Platine\Collection\Exception |
40 | 40 | */ |
41 | -class InvalidOperationException extends Exception |
|
42 | -{ |
|
41 | +class InvalidOperationException extends Exception { |
|
43 | 42 | } |
@@ -70,8 +70,7 @@ discard block |
||
70 | 70 | * Create new instance |
71 | 71 | * @param array<mixed, mixed> $initials |
72 | 72 | */ |
73 | - public function __construct(array $initials = []) |
|
74 | - { |
|
73 | + public function __construct(array $initials = []) { |
|
75 | 74 | $this->data = new DataContainer($initials); |
76 | 75 | } |
77 | 76 | |
@@ -108,8 +107,7 @@ discard block |
||
108 | 107 | * Return the first element of collection |
109 | 108 | * @return mixed |
110 | 109 | */ |
111 | - public function first() |
|
112 | - { |
|
110 | + public function first() { |
|
113 | 111 | if ($this->isEmpty()) { |
114 | 112 | throw new OutOfRangeException('The collection is empty'); |
115 | 113 | } |
@@ -122,8 +120,7 @@ discard block |
||
122 | 120 | * Return the last element of collection |
123 | 121 | * @return mixed |
124 | 122 | */ |
125 | - public function last() |
|
126 | - { |
|
123 | + public function last() { |
|
127 | 124 | if ($this->isEmpty()) { |
128 | 125 | throw new OutOfRangeException('The collection is empty'); |
129 | 126 | } |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @package Platine\Collection |
52 | 52 | * @template T |
53 | 53 | */ |
54 | -interface MergeableInterface |
|
55 | -{ |
|
54 | +interface MergeableInterface { |
|
56 | 55 | |
57 | 56 | /** |
58 | 57 | * Merge with the given collection |
@@ -58,5 +58,5 @@ |
||
58 | 58 | * @param callable $callback |
59 | 59 | * @return void |
60 | 60 | */ |
61 | - public function forEach(callable $callback): void; |
|
61 | + public function forEach (callable $callback): void; |
|
62 | 62 | } |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class IterableInterface |
51 | 51 | * @package Platine\Collection |
52 | 52 | */ |
53 | -interface IterableInterface |
|
54 | -{ |
|
53 | +interface IterableInterface { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * Loop on each collection element with the given callback |
@@ -58,5 +58,5 @@ |
||
58 | 58 | * @param callable $callback |
59 | 59 | * @return void |
60 | 60 | */ |
61 | - public function forEach(callable $callback): void; |
|
61 | + public function foreach(callable $callback): void; |
|
62 | 62 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $diffValues = array_udiff( |
107 | 107 | $this->all(), |
108 | 108 | $collection->all(), |
109 | - function ($a, $b) { |
|
109 | + function($a, $b) { |
|
110 | 110 | if (gettype($a) !== gettype($b)) { |
111 | 111 | return -1; |
112 | 112 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * {@inheritedoc} |
158 | 158 | */ |
159 | - public function forEach(callable $callback): void |
|
159 | + public function forEach (callable $callback): void |
|
160 | 160 | { |
161 | 161 | $data = $this->all(); |
162 | 162 | array_walk($data, $callback); |
@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | /** |
168 | 168 | * {@inheritedoc} |
169 | 169 | */ |
170 | - public function get(int $offset) |
|
171 | - { |
|
170 | + public function get(int $offset) { |
|
172 | 171 | return $this->data->offsetGet($offset); |
173 | 172 | } |
174 | 173 | |
@@ -198,8 +197,7 @@ discard block |
||
198 | 197 | * Return a random element of the collection |
199 | 198 | * @return mixed |
200 | 199 | */ |
201 | - public function rand() |
|
202 | - { |
|
200 | + public function rand() { |
|
203 | 201 | if ($this->isEmpty()) { |
204 | 202 | throw new InvalidOperationException('The collection is empty'); |
205 | 203 | } |
@@ -156,7 +156,7 @@ |
||
156 | 156 | /** |
157 | 157 | * {@inheritedoc} |
158 | 158 | */ |
159 | - public function forEach(callable $callback): void |
|
159 | + public function foreach(callable $callback): void |
|
160 | 160 | { |
161 | 161 | $data = $this->all(); |
162 | 162 | array_walk($data, $callback); |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @package Platine\Collection |
52 | 52 | * @template T |
53 | 53 | */ |
54 | -interface SortableInterface |
|
55 | -{ |
|
54 | +interface SortableInterface { |
|
56 | 55 | |
57 | 56 | /** |
58 | 57 | * Sort the collection |
@@ -70,8 +70,7 @@ discard block |
||
70 | 70 | * Create new instance |
71 | 71 | * @param array<mixed, mixed> $data |
72 | 72 | */ |
73 | - public function __construct(array $data = []) |
|
74 | - { |
|
73 | + public function __construct(array $data = []) { |
|
75 | 74 | $this->data = $data; |
76 | 75 | } |
77 | 76 | |
@@ -121,8 +120,7 @@ discard block |
||
121 | 120 | * @param mixed $offset |
122 | 121 | * @return mixed |
123 | 122 | */ |
124 | - public function offsetGet($offset) |
|
125 | - { |
|
123 | + public function offsetGet($offset) { |
|
126 | 124 | return isset($this->data[$offset]) |
127 | 125 | ? $this->data[$offset] |
128 | 126 | : null; |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class CollectionInterface |
51 | 51 | * @package Platine\Collection |
52 | 52 | */ |
53 | -interface CollectionInterface |
|
54 | -{ |
|
53 | +interface CollectionInterface { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * Add element to the collection |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class TypeCheck |
53 | 53 | * @package Platine\Collection |
54 | 54 | */ |
55 | -class TypeCheck |
|
56 | -{ |
|
55 | +class TypeCheck { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * |