| Conditions | 3 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function transform($response, $transformer, Binding $binding, Request $request) |
||
| 20 | { |
||
| 21 | // 过滤掉未允许的 include 项 |
||
| 22 | $include_manager = app(IncludeManager::class); |
||
| 23 | $this->fractal->parseIncludes($include_manager->figureOutWhichIncludes()); |
||
| 24 | |||
| 25 | $resource = $this->createResource($response, $transformer, $binding->getParameters()); |
||
| 26 | |||
| 27 | // If the response is a paginator then we'll create a new paginator |
||
| 28 | // adapter for Laravel and set the paginator instance on our |
||
| 29 | // collection resource. |
||
| 30 | if ($response instanceof IlluminatePaginator) { |
||
| 31 | $paginator = $this->createPaginatorAdapter($response); |
||
| 32 | |||
| 33 | $resource->setPaginator($paginator); |
||
|
|
|||
| 34 | } |
||
| 35 | |||
| 36 | foreach ($binding->getMeta() as $key => $value) { |
||
| 37 | $resource->setMetaValue($key, $value); |
||
| 38 | } |
||
| 39 | |||
| 40 | $binding->fireCallback($resource, $this->fractal); |
||
| 41 | |||
| 42 | return $this->fractal->createData($resource)->toArray(); |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: