__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php /* * This file is part of JSON-API. * * (c) Toby Zerner <[email protected]> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Tobscure\JsonApi; class Collection implements ElementInterface { /** * @var array */ protected $resources = []; /** * Create a new collection instance. * * @param mixed $data * @param \Tobscure\JsonApi\SerializerInterface $serializer */ public function __construct($data, SerializerInterface $serializer) { $this->resources = $this->buildResources($data, $serializer); } /** * Convert an array of raw data to Resource objects. * * @param mixed $data * @param SerializerInterface $serializer * * @return \Tobscure\JsonApi\Resource[] */ protected function buildResources($data, SerializerInterface $serializer) { $resources = []; foreach ($data as $resource) { if (! ($resource instanceof Resource)) { $resource = new Resource($resource, $serializer); } $resources[] = $resource; } return $resources; } /** * {@inheritdoc} */ public function getResources() { return $this->resources; } /** * Set the resources array. * * @param array $resources * * @return void */ public function setResources($resources) { $this->resources = $resources; } /** * Request a relationship to be included for all resources. * * @param string|array $relationships * * @return $this */ public function with($relationships) { foreach ($this->resources as $resource) { $resource->with($relationships); } return $this; } /** * Request a restricted set of fields. * * @param array|null $fields * * @return $this */ public function fields($fields) { foreach ($this->resources as $resource) { $resource->fields($fields); } return $this; } /** * {@inheritdoc} */ public function toArray() { return array_map(function (Resource $resource) { return $resource->toArray(); }, $this->resources); } /** * {@inheritdoc} */ public function toIdentifier() { return array_map(function (Resource $resource) { return $resource->toIdentifier(); }, $this->resources); } }
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Exception | Folder | 0775 |
|
|
| AbstractSerializer.php | File | 2.08 KB | 0664 |
|
| Collection.php | File | 2.58 KB | 0664 |
|
| Document.php | File | 5.04 KB | 0664 |
|
| ElementInterface.php | File | 994 B | 0664 |
|
| ErrorHandler.php | File | 1.31 KB | 0664 |
|
| LinksTrait.php | File | 3.24 KB | 0664 |
|
| MetaTrait.php | File | 956 B | 0664 |
|
| Parameters.php | File | 4.59 KB | 0664 |
|
| Relationship.php | File | 1.49 KB | 0664 |
|
| Resource.php | File | 8.79 KB | 0664 |
|
| SerializerInterface.php | File | 1.24 KB | 0664 |
|
| Util.php | File | 1.12 KB | 0664 |
|