| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | interface FractalService |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Serializes a single item. |
||
| 14 | * |
||
| 15 | * @param mixed $data |
||
| 16 | * @param TransformerAbstract|callable|null $transformer |
||
| 17 | * @param string|null $resourceKey |
||
| 18 | * |
||
| 19 | * @return FractalBuilder |
||
| 20 | */ |
||
| 21 | public function item($data, TransformerAbstract $transformer = null, $resourceKey = null); |
||
| 22 | |||
| 23 | |||
| 24 | /** |
||
| 25 | * Serializes a collection of items. |
||
| 26 | * |
||
| 27 | * @param mixed $data |
||
| 28 | * @param TransformerAbstract|callable|null $transformer |
||
| 29 | * @param string|null $resourceKey |
||
| 30 | * |
||
| 31 | * @return FractalBuilder |
||
| 32 | */ |
||
| 33 | public function collection($data, TransformerAbstract $transformer = null, $resourceKey = null); |
||
| 34 | |||
| 35 | |||
| 36 | /** |
||
| 37 | * Parses includes from either a string (GET query parameter) or an array |
||
| 38 | * and stores them so that they are available at the time of serialization. |
||
| 39 | * |
||
| 40 | * @param string|array $includes |
||
| 41 | * |
||
| 42 | * @see http://fractal.thephpleague.com/transformers#including-data |
||
| 43 | */ |
||
| 44 | public function parseIncludes($includes); |
||
| 45 | |||
| 46 | |||
| 47 | /** |
||
| 48 | * Sets the default serializer to use for serializing data. |
||
| 49 | * |
||
| 50 | * @param SerializerAbstract $serializer |
||
| 51 | * |
||
| 52 | * @see http://fractal.thephpleague.com/serializers/ |
||
| 53 | */ |
||
| 54 | public function setDefaultSerializer(SerializerAbstract $serializer); |
||
| 55 | } |
||
| 56 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: