| Total Complexity | 6 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class CollectionExport |
||
| 18 | { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Array of collection items. |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | private $collection; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Initiate the CollectionExport object. |
||
| 28 | * @param array $collection The collection array. |
||
| 29 | */ |
||
| 30 | 11 | public function __construct(array $collection) |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * The total number of items in the collection. |
||
| 37 | * @return integer |
||
| 38 | */ |
||
| 39 | 1 | public function count() |
|
| 40 | { |
||
| 41 | 1 | return count($this->collection); |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Return the contents of the collection as an array. |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | 8 | public function toArray() |
|
| 49 | { |
||
| 50 | 8 | return $this->collection; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Return the contents of the collection as an stdClass object. |
||
| 55 | * @return object |
||
| 56 | */ |
||
| 57 | 1 | public function toObject() |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Return the contents of the collection as a JSON encoded string. |
||
| 64 | * @return string |
||
| 65 | */ |
||
| 66 | 2 | public function toJson() |
|
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Default return value on the object, will return the collection as JSON representation. |
||
| 73 | * @return string |
||
| 74 | */ |
||
| 75 | 1 | public function __toString() |
|
| 78 | } |
||
| 79 | } |
||
| 80 |