@@ -15,123 +15,123 @@ |
||
| 15 | 15 | |
| 16 | 16 | class MeCollection |
| 17 | 17 | { |
| 18 | - public static function fromList($values) |
|
| 19 | - { |
|
| 20 | - $collections = array(); |
|
| 21 | - |
|
| 22 | - foreach ($values as $value) { |
|
| 23 | - $collections[$value->base_id] = self::fromValue($value); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - return $collections; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function fromValue(\stdClass $value) |
|
| 30 | - { |
|
| 31 | - return new self($value); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var \stdClass |
|
| 36 | - */ |
|
| 37 | - protected $source; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var ArrayCollection |
|
| 41 | - */ |
|
| 42 | - protected $labels; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @param \stdClass $source |
|
| 46 | - */ |
|
| 47 | - public function __construct(\stdClass $source) |
|
| 48 | - { |
|
| 49 | - $this->source = $source; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @return \stdClass |
|
| 54 | - */ |
|
| 55 | - public function getRawData() |
|
| 56 | - { |
|
| 57 | - return $this->source; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The logo base64 |
|
| 62 | - * |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 65 | - public function getLogo() |
|
| 66 | - { |
|
| 67 | - return $this->source->logo; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The collection base id |
|
| 72 | - * |
|
| 73 | - * @return integer |
|
| 74 | - */ |
|
| 75 | - public function getBaseId() |
|
| 76 | - { |
|
| 77 | - return $this->source->base_id; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * The databox id |
|
| 82 | - * |
|
| 83 | - * @return integer |
|
| 84 | - */ |
|
| 85 | - public function getDataboxId() |
|
| 86 | - { |
|
| 87 | - return $this->source->databox_id; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * The collection id |
|
| 92 | - * |
|
| 93 | - * @return integer |
|
| 94 | - */ |
|
| 95 | - public function getCollectionId() |
|
| 96 | - { |
|
| 97 | - return $this->source->collection_id; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * The collection name |
|
| 102 | - * |
|
| 103 | - * @return string |
|
| 104 | - */ |
|
| 105 | - public function getName() |
|
| 106 | - { |
|
| 107 | - return $this->source->name; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * The collection rights |
|
| 112 | - * |
|
| 113 | - * @return array |
|
| 114 | - */ |
|
| 115 | - public function getRights() |
|
| 116 | - { |
|
| 117 | - return $this->source->rights; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * The collection rights |
|
| 122 | - * |
|
| 123 | - * @return array |
|
| 124 | - */ |
|
| 125 | - public function getStatuses() |
|
| 126 | - { |
|
| 127 | - return $this->source->statuses; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @return ArrayCollection|string[] |
|
| 132 | - */ |
|
| 133 | - public function getLabels() |
|
| 134 | - { |
|
| 135 | - return $this->labels ?: $this->labels = new ArrayCollection((array) $this->source->labels); |
|
| 136 | - } |
|
| 18 | + public static function fromList($values) |
|
| 19 | + { |
|
| 20 | + $collections = array(); |
|
| 21 | + |
|
| 22 | + foreach ($values as $value) { |
|
| 23 | + $collections[$value->base_id] = self::fromValue($value); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + return $collections; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function fromValue(\stdClass $value) |
|
| 30 | + { |
|
| 31 | + return new self($value); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var \stdClass |
|
| 36 | + */ |
|
| 37 | + protected $source; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var ArrayCollection |
|
| 41 | + */ |
|
| 42 | + protected $labels; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @param \stdClass $source |
|
| 46 | + */ |
|
| 47 | + public function __construct(\stdClass $source) |
|
| 48 | + { |
|
| 49 | + $this->source = $source; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @return \stdClass |
|
| 54 | + */ |
|
| 55 | + public function getRawData() |
|
| 56 | + { |
|
| 57 | + return $this->source; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The logo base64 |
|
| 62 | + * |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | + public function getLogo() |
|
| 66 | + { |
|
| 67 | + return $this->source->logo; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The collection base id |
|
| 72 | + * |
|
| 73 | + * @return integer |
|
| 74 | + */ |
|
| 75 | + public function getBaseId() |
|
| 76 | + { |
|
| 77 | + return $this->source->base_id; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * The databox id |
|
| 82 | + * |
|
| 83 | + * @return integer |
|
| 84 | + */ |
|
| 85 | + public function getDataboxId() |
|
| 86 | + { |
|
| 87 | + return $this->source->databox_id; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * The collection id |
|
| 92 | + * |
|
| 93 | + * @return integer |
|
| 94 | + */ |
|
| 95 | + public function getCollectionId() |
|
| 96 | + { |
|
| 97 | + return $this->source->collection_id; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * The collection name |
|
| 102 | + * |
|
| 103 | + * @return string |
|
| 104 | + */ |
|
| 105 | + public function getName() |
|
| 106 | + { |
|
| 107 | + return $this->source->name; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * The collection rights |
|
| 112 | + * |
|
| 113 | + * @return array |
|
| 114 | + */ |
|
| 115 | + public function getRights() |
|
| 116 | + { |
|
| 117 | + return $this->source->rights; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * The collection rights |
|
| 122 | + * |
|
| 123 | + * @return array |
|
| 124 | + */ |
|
| 125 | + public function getStatuses() |
|
| 126 | + { |
|
| 127 | + return $this->source->statuses; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @return ArrayCollection|string[] |
|
| 132 | + */ |
|
| 133 | + public function getLabels() |
|
| 134 | + { |
|
| 135 | + return $this->labels ?: $this->labels = new ArrayCollection((array) $this->source->labels); |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | \ No newline at end of file |
@@ -18,21 +18,21 @@ |
||
| 18 | 18 | |
| 19 | 19 | class MeCollection extends AbstractRepository |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Return all collections available |
|
| 23 | - * |
|
| 24 | - * @return MeCollection[] |
|
| 25 | - * @throws NotFoundException |
|
| 26 | - * @throws UnauthorizedException |
|
| 27 | - */ |
|
| 28 | - public function getCollectionsList() |
|
| 29 | - { |
|
| 30 | - $response = $this->query('GET', 'v1/me/collections/'); |
|
| 21 | + /** |
|
| 22 | + * Return all collections available |
|
| 23 | + * |
|
| 24 | + * @return MeCollection[] |
|
| 25 | + * @throws NotFoundException |
|
| 26 | + * @throws UnauthorizedException |
|
| 27 | + */ |
|
| 28 | + public function getCollectionsList() |
|
| 29 | + { |
|
| 30 | + $response = $this->query('GET', 'v1/me/collections/'); |
|
| 31 | 31 | |
| 32 | - if ($response->hasProperty(('collections')) !== true) { |
|
| 33 | - throw new RuntimeException('Missing "collections" property in response content'); |
|
| 34 | - } |
|
| 32 | + if ($response->hasProperty(('collections')) !== true) { |
|
| 33 | + throw new RuntimeException('Missing "collections" property in response content'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return \PhraseanetSDK\Entity\MeCollection::fromList($response->getProperty('collections')); |
|
| 37 | - } |
|
| 36 | + return \PhraseanetSDK\Entity\MeCollection::fromList($response->getProperty('collections')); |
|
| 37 | + } |
|
| 38 | 38 | } |