@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Serializes a single item. |
14 | 14 | * |
15 | 15 | * @param mixed $data |
16 | - * @param TransformerAbstract|callable|null $transformer |
|
16 | + * @param null|TransformerAbstract $transformer |
|
17 | 17 | * @param string|null $resourceKey |
18 | 18 | * |
19 | 19 | * @return FractalBuilder |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * Serializes a collection of items. |
26 | 26 | * |
27 | 27 | * @param mixed $data |
28 | - * @param TransformerAbstract|callable|null $transformer |
|
28 | + * @param null|TransformerAbstract $transformer |
|
29 | 29 | * @param string|null $resourceKey |
30 | 30 | * |
31 | 31 | * @return FractalBuilder |
@@ -40,6 +40,7 @@ discard block |
||
40 | 40 | * @param string|array $includes |
41 | 41 | * |
42 | 42 | * @see http://fractal.thephpleague.com/transformers#including-data |
43 | + * @return void |
|
43 | 44 | */ |
44 | 45 | public function parseIncludes($includes); |
45 | 46 | |
@@ -50,6 +51,7 @@ discard block |
||
50 | 51 | * @param SerializerAbstract $serializer |
51 | 52 | * |
52 | 53 | * @see http://fractal.thephpleague.com/serializers/ |
54 | + * @return void |
|
53 | 55 | */ |
54 | 56 | public function setDefaultSerializer(SerializerAbstract $serializer); |
55 | 57 | } |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Illuminate\Contracts\Config\Repository as ConfigRepository; |
6 | 6 | use Illuminate\Contracts\Container\Container; |
7 | 7 | use Illuminate\Support\ServiceProvider; |
8 | -use Laravel\Lumen\Application; |
|
9 | 8 | use Nord\Lumen\Fractal\Contracts\FractalService as FractalServiceContract; |
10 | 9 | |
11 | 10 | class FractalServiceProvider extends ServiceProvider |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | protected function registerBindings(Container $container, ConfigRepository $config) |
32 | 32 | { |
33 | - $container->singleton(FractalService::class, function () use ($config) { |
|
33 | + $container->singleton(FractalService::class, function() use ($config) { |
|
34 | 34 | $fractal = new FractalService(); |
35 | 35 | |
36 | 36 | $this->configureService($fractal, $config[self::CONFIG_KEY]); |
@@ -34,11 +34,11 @@ |
||
34 | 34 | */ |
35 | 35 | public function testAssertParseInclude() |
36 | 36 | { |
37 | - $this->specify('verify middleware parse include', function () { |
|
37 | + $this->specify('verify middleware parse include', function() { |
|
38 | 38 | $req = new Request(); |
39 | 39 | $req->offsetSet('include', 'foo,bar,baz'); |
40 | 40 | |
41 | - verify($this->middleware->handle($req, function () { |
|
41 | + verify($this->middleware->handle($req, function() { |
|
42 | 42 | return true; |
43 | 43 | }))->equals(true); |
44 | 44 | }); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function testAssertCanBeRegistered() |
32 | 32 | { |
33 | - $this->specify('verify serviceProvider is registered', function () { |
|
33 | + $this->specify('verify serviceProvider is registered', function() { |
|
34 | 34 | $service = $this->app->make(FractalService::class); |
35 | 35 | verify($service)->isInstanceOf(FractalService::class); |
36 | 36 | }); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function testAssertFacade() |
43 | 43 | { |
44 | - $this->specify('verify serviceProvider facade', function () { |
|
44 | + $this->specify('verify serviceProvider facade', function() { |
|
45 | 45 | verify(FractalFacade::getFacadeRoot())->isInstanceOf(FractalService::class); |
46 | 46 | }); |
47 | 47 | } |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function testItem() |
55 | 55 | { |
56 | - $this->specify('The key "data" is required.', function () { |
|
56 | + $this->specify('The key "data" is required.', function() { |
|
57 | 57 | $item = $this->service->item($this->book, $this->transformer)->toArray(); |
58 | 58 | verify($item)->hasKey('data'); |
59 | 59 | }); |
60 | 60 | |
61 | - $this->specify('The book title must equal "Test Book".', function () { |
|
61 | + $this->specify('The book title must equal "Test Book".', function() { |
|
62 | 62 | $item = $this->service->item($this->book, $this->transformer)->toArray(); |
63 | 63 | verify($item['data']['title'])->equals('Test Book'); |
64 | 64 | }); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function testCollection() |
71 | 71 | { |
72 | - $this->specify('Array does not contain specified amount of items', function () { |
|
72 | + $this->specify('Array does not contain specified amount of items', function() { |
|
73 | 73 | $collection = $this->service->collection([$this->book], $this->transformer)->toArray(); |
74 | 74 | verify(count($collection['data']))->equals(1); |
75 | 75 | verify(count($collection['data']))->equals(1); |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function testAuthorInclude() |
83 | 83 | { |
84 | - $this->specify('The key "data" is required.', function () { |
|
84 | + $this->specify('The key "data" is required.', function() { |
|
85 | 85 | $item = $this->service->item($this->book, $this->transformer)->toArray(); |
86 | 86 | verify($item)->hasKey('data'); |
87 | 87 | }); |
88 | 88 | |
89 | - $this->specify('Author last name must be "Author".', function () { |
|
89 | + $this->specify('Author last name must be "Author".', function() { |
|
90 | 90 | $item = $this->service->item($this->book, $this->transformer)->toArray(); |
91 | 91 | verify($item['data']['author'])->hasKey('data'); |
92 | 92 | verify($item['data']['author']['data'])->hasKey('lastName'); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'foo' => 'bar' |
104 | 104 | ]; |
105 | 105 | |
106 | - $this->specify('The key "meta" is required for item.', function () use ($meta) { |
|
106 | + $this->specify('The key "meta" is required for item.', function() use ($meta) { |
|
107 | 107 | $item = $this->service->item($this->book, $this->transformer) |
108 | 108 | ->setMeta($meta) |
109 | 109 | ->toArray(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | verify($item['meta'])->equals($meta); |
112 | 112 | }); |
113 | 113 | |
114 | - $this->specify('The key "meta" is required for collection.', function () use ($meta) { |
|
114 | + $this->specify('The key "meta" is required for collection.', function() use ($meta) { |
|
115 | 115 | $collection = $this->service->collection([$this->book], $this->transformer) |
116 | 116 | ->setMeta($meta) |
117 | 117 | ->toArray(); |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testAssertJson() |
127 | 127 | { |
128 | - $this->specify('The item has to be in JSON format.', function () { |
|
128 | + $this->specify('The item has to be in JSON format.', function() { |
|
129 | 129 | $item = $this->service->item($this->book, $this->transformer)->toJson(); |
130 | 130 | verify($item)->equals('{"data":{"title":"Test Book","publisher":"Test Publisher","author":{"data":{"firstName":"Test","lastName":"Author"}}}}'); |
131 | 131 | }); |
132 | 132 | |
133 | - $this->specify('The collection has to be in JSON format.', function () { |
|
133 | + $this->specify('The collection has to be in JSON format.', function() { |
|
134 | 134 | $collection = $this->service->collection([$this->book], $this->transformer)->toJson(); |
135 | 135 | verify($collection)->equals('{"data":[{"title":"Test Book","publisher":"Test Publisher","author":{"data":{"firstName":"Test","lastName":"Author"}}}]}'); |
136 | 136 | }); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function testAssertSerializer() |
143 | 143 | { |
144 | - $this->specify('The serializer is array serializer', function () { |
|
144 | + $this->specify('The serializer is array serializer', function() { |
|
145 | 145 | $builder = $this->service->item($this->book, $this->transformer); |
146 | 146 | $builder->setSerializer(new ArraySerializer()); |
147 | 147 | $item = $builder->toArray(); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | ]); |
156 | 156 | }); |
157 | 157 | |
158 | - $this->specify('The serializer is data array serializer', function () { |
|
158 | + $this->specify('The serializer is data array serializer', function() { |
|
159 | 159 | $builder = $this->service->item($this->book, $this->transformer); |
160 | 160 | $builder->setSerializer(new DataArraySerializer()); |
161 | 161 | $item = $builder->toArray(); |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function testAssertResourceKey() |
181 | 181 | { |
182 | - $this->specify('The fractal builder resource key can be set.', function () { |
|
182 | + $this->specify('The fractal builder resource key can be set.', function() { |
|
183 | 183 | $item = $this->service->item($this->book, $this->transformer); |
184 | 184 | $item->setResourceKey('book'); |
185 | 185 | $array = $item->toArray(); |
186 | 186 | verify($array)->hasKey('data'); |
187 | 187 | }); |
188 | 188 | |
189 | - $this->specify('The fractal service can set the builder resource key.', function () { |
|
189 | + $this->specify('The fractal service can set the builder resource key.', function() { |
|
190 | 190 | $item = $this->service->item($this->book, $this->transformer, 'book')->toArray(); |
191 | 191 | verify($item)->hasKey('data'); |
192 | 192 | }); |
193 | 193 | |
194 | - $this->specify('The fractal builder resource key has to be valid.', function () { |
|
194 | + $this->specify('The fractal builder resource key has to be valid.', function() { |
|
195 | 195 | $item = $this->service->item($this->book, $this->transformer); |
196 | 196 | $item->setResourceKey(123); |
197 | 197 | }, ['throws' => 'Nord\Lumen\Fractal\Exceptions\InvalidArgument']); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function testAssertPaginator() |
204 | 204 | { |
205 | - $this->specify('The collection can have a paginator', function () { |
|
205 | + $this->specify('The collection can have a paginator', function() { |
|
206 | 206 | $books = [$this->book]; |
207 | 207 | $collection = $this->service->collection($books, $this->transformer) |
208 | 208 | ->setPaginator(new BookPaginator($books)) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | verify($collection['meta'])->hasKey('pagination'); |
212 | 212 | }); |
213 | 213 | |
214 | - $this->specify('The item cannot have a paginator', function () { |
|
214 | + $this->specify('The item cannot have a paginator', function() { |
|
215 | 215 | $this->service->item($this->book, $this->transformer) |
216 | 216 | ->setPaginator(new BookPaginator([])) |
217 | 217 | ->toArray(); |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function testAssertCursor() |
225 | 225 | { |
226 | - $this->specify('The collection can have a cursor', function () { |
|
226 | + $this->specify('The collection can have a cursor', function() { |
|
227 | 227 | $collection = $this->service->collection([$this->book], $this->transformer) |
228 | 228 | ->setCursor(new Cursor()) |
229 | 229 | ->toArray(); |
230 | 230 | verify(count($collection['data']))->equals(1); |
231 | 231 | }); |
232 | 232 | |
233 | - $this->specify('The item cannot have a cursor', function () { |
|
233 | + $this->specify('The item cannot have a cursor', function() { |
|
234 | 234 | $this->service->item($this->book, $this->transformer) |
235 | 235 | ->setCursor(new Cursor()) |
236 | 236 | ->toArray(); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | // Here you can initialize variables that will be available to your tests |
3 | 3 | |
4 | -require_once __DIR__ . '/../_support/Mock/MockApplication.php'; |
|
4 | +require_once __DIR__.'/../_support/Mock/MockApplication.php'; |