@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | 'project' => Project::class |
| 29 | 29 | ]; |
| 30 | 30 | |
| 31 | - final public function __toString (): string { |
|
| 31 | + final public function __toString(): string { |
|
| 32 | 32 | return "sections/{$this->getGid()}"; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - final protected function _getDir (): string { |
|
| 35 | + final protected function _getDir(): string { |
|
| 36 | 36 | return "{$this->getProject()}/sections"; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return Task[] |
| 45 | 45 | */ |
| 46 | - public function getTasks () { |
|
| 46 | + public function getTasks() { |
|
| 47 | 47 | return $this->loadAll(Task::class, 'tasks', ['section' => $this->getGid()]); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @depends after-create |
| 54 | 54 | * @return Task |
| 55 | 55 | */ |
| 56 | - public function newTask () { |
|
| 56 | + public function newTask() { |
|
| 57 | 57 | /** @var Task $task */ |
| 58 | 58 | $task = $this->factory(Task::class); |
| 59 | 59 | return $task->addToProject($this->getProject(), $this); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param AbstractEntity $entity |
| 35 | 35 | * @return bool Success |
| 36 | 36 | */ |
| 37 | - public function add (AbstractEntity $entity): bool { |
|
| 37 | + public function add(AbstractEntity $entity): bool { |
|
| 38 | 38 | if ($gid = $entity->getGid() and !$entity->isDiff()) { |
| 39 | 39 | $this->entities[$gid] = $entity; |
| 40 | 40 | $this->addKeys($gid, $entity->getCacheKeys()); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $gid |
| 50 | 50 | * @param string[] $keys |
| 51 | 51 | */ |
| 52 | - protected function addKeys (string $gid, array $keys): void { |
|
| 52 | + protected function addKeys(string $gid, array $keys): void { |
|
| 53 | 53 | $this->gids += array_fill_keys($keys, $gid); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param Closure $factory `fn( Api|Data $caller ): null|AbstractEntity` |
| 65 | 65 | * @return null|mixed|AbstractEntity |
| 66 | 66 | */ |
| 67 | - public function get (string $key, $caller, Closure $factory) { |
|
| 67 | + public function get(string $key, $caller, Closure $factory) { |
|
| 68 | 68 | // POOL HIT |
| 69 | 69 | if ($gid = $this->gids[$key] ?? null) { |
| 70 | 70 | return $this->entities[$gid]; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @param AbstractEntity $entity |
| 94 | 94 | */ |
| 95 | - public function remove (AbstractEntity $entity): void { |
|
| 95 | + public function remove(AbstractEntity $entity): void { |
|
| 96 | 96 | $gid = $entity->getGid(); |
| 97 | 97 | unset($this->entities[$gid]); |
| 98 | 98 | foreach ($entity->getCacheKeys() as $key) { |
@@ -12,5 +12,5 @@ |
||
| 12 | 12 | * @param string $path |
| 13 | 13 | * @param null|array $data |
| 14 | 14 | */ |
| 15 | - public function log (string $message, string $path, array $data = null): void; |
|
| 15 | + public function log(string $message, string $path, array $data = null): void; |
|
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | * |
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | - abstract protected function _getDir (): string; |
|
| 15 | + abstract protected function _getDir(): string; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * `POST` the new entity to Asana. |
| 19 | 19 | * |
| 20 | 20 | * @return $this |
| 21 | 21 | */ |
| 22 | - public function create () { |
|
| 22 | + public function create() { |
|
| 23 | 23 | return $this->{'_save'}($this->_getDir()); |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * `DELETE` |
| 12 | 12 | */ |
| 13 | - public function delete (): void { |
|
| 13 | + public function delete(): void { |
|
| 14 | 14 | $this->{'_delete'}(); |
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | * |
| 13 | 13 | * @return $this |
| 14 | 14 | */ |
| 15 | - public function update () { |
|
| 15 | + public function update() { |
|
| 16 | 16 | return $this->{'_save'}(); |
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |
@@ -218,8 +218,7 @@ discard block |
||
| 218 | 218 | if (is_array($class)) { |
| 219 | 219 | $class = $class[0]; |
| 220 | 220 | $this->data[$field] = array_map($hydrate, $value); |
| 221 | - } |
|
| 222 | - else { |
|
| 221 | + } else { |
|
| 223 | 222 | $this->data[$field] = $hydrate($value); |
| 224 | 223 | } |
| 225 | 224 | } |
@@ -324,11 +323,9 @@ discard block |
||
| 324 | 323 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
| 325 | 324 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
| 326 | 325 | return $each->getGid(); |
| 327 | - } |
|
| 328 | - elseif ($each instanceof self) { |
|
| 326 | + } elseif ($each instanceof self) { |
|
| 329 | 327 | return $each->toArray(); |
| 330 | - } |
|
| 331 | - elseif (is_array($each)) { |
|
| 328 | + } elseif (is_array($each)) { |
|
| 332 | 329 | return array_map($dehydrate, $each); |
| 333 | 330 | } |
| 334 | 331 | return $each; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param Api|Data $caller |
| 48 | 48 | * @param array $data |
| 49 | 49 | */ |
| 50 | - public function __construct ($caller, array $data = []) { |
|
| 50 | + public function __construct($caller, array $data = []) { |
|
| 51 | 51 | $this->api = $caller instanceof self ? $caller->api : $caller; |
| 52 | 52 | $this->_setData($data); |
| 53 | 53 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | * @param array $args |
| 64 | 64 | * @return mixed |
| 65 | 65 | */ |
| 66 | - public function __call (string $method, array $args) { |
|
| 66 | + public function __call(string $method, array $args) { |
|
| 67 | 67 | static $cache = []; |
| 68 | - if (!$call =& $cache[$method]) { |
|
| 68 | + if (!$call = & $cache[$method]) { |
|
| 69 | 69 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
| 70 | 70 | $call[1] = '_' . $call[1]; |
| 71 | 71 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | return $this->{$call[1]}($call[2], ...$args); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function __debugInfo (): array { |
|
| 78 | + public function __debugInfo(): array { |
|
| 79 | 79 | return $this->data; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param $field |
| 86 | 86 | * @return null|Data|mixed |
| 87 | 87 | */ |
| 88 | - final public function __get ($field) { |
|
| 88 | + final public function __get($field) { |
|
| 89 | 89 | return $this->_get($field); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param $field |
| 98 | 98 | * @return bool |
| 99 | 99 | */ |
| 100 | - final public function __isset ($field) { |
|
| 100 | + final public function __isset($field) { |
|
| 101 | 101 | return true; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param string $field |
| 110 | 110 | * @return mixed |
| 111 | 111 | */ |
| 112 | - protected function _get (string $field) { |
|
| 112 | + protected function _get(string $field) { |
|
| 113 | 113 | return $this->data[$field] ?? null; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param string $field |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | - protected function _has (string $field): bool { |
|
| 126 | + protected function _has(string $field): bool { |
|
| 127 | 127 | $value = $this->_get($field); |
| 128 | 128 | if (isset($value)) { |
| 129 | 129 | if (is_countable($value)) { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param string $field |
| 147 | 147 | * @return bool |
| 148 | 148 | */ |
| 149 | - protected function _is (string $field): bool { |
|
| 149 | + protected function _is(string $field): bool { |
|
| 150 | 150 | return !empty($this->_get($field)); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param callable $filter `fn( Data $object ): bool` |
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | - protected function _select ($subject, callable $filter) { |
|
| 164 | + protected function _select($subject, callable $filter) { |
|
| 165 | 165 | if (!is_array($subject)) { |
| 166 | 166 | $subject = $this->_get($subject) ?? []; |
| 167 | 167 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @param mixed $value |
| 178 | 178 | * @return $this |
| 179 | 179 | */ |
| 180 | - protected function _set (string $field, $value) { |
|
| 180 | + protected function _set(string $field, $value) { |
|
| 181 | 181 | $this->data[$field] = $value; |
| 182 | 182 | $this->diff[$field] = true; |
| 183 | 183 | return $this; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @param array $data |
| 190 | 190 | */ |
| 191 | - protected function _setData (array $data): void { |
|
| 191 | + protected function _setData(array $data): void { |
|
| 192 | 192 | $this->data = $this->diff = []; |
| 193 | 193 | foreach ($data as $field => $value) { |
| 194 | 194 | $this->_setMapped($field, $value); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param string $field |
| 202 | 202 | * @param mixed $value |
| 203 | 203 | */ |
| 204 | - protected function _setMapped (string $field, $value): void { |
|
| 204 | + protected function _setMapped(string $field, $value): void { |
|
| 205 | 205 | unset($this->diff[$field]); |
| 206 | 206 | |
| 207 | 207 | // use value as-is? |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param array $data |
| 250 | 250 | * @return mixed|Data|AbstractEntity |
| 251 | 251 | */ |
| 252 | - final protected function factory (string $class, array $data = []) { |
|
| 252 | + final protected function factory(string $class, array $data = []) { |
|
| 253 | 253 | return $this->api->factory($class, $this, $data); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return array |
| 260 | 260 | */ |
| 261 | - public function getDiff (): array { |
|
| 261 | + public function getDiff(): array { |
|
| 262 | 262 | $convert = function($each) use (&$convert) { |
| 263 | 263 | // convert existing entities to gids |
| 264 | 264 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param string null $field |
| 285 | 285 | * @return bool |
| 286 | 286 | */ |
| 287 | - final public function isDiff (string $field = null): bool { |
|
| 287 | + final public function isDiff(string $field = null): bool { |
|
| 288 | 288 | if ($field) { |
| 289 | 289 | return isset($this->diff[$field]); |
| 290 | 290 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @see toArray() |
| 296 | 296 | * @return array |
| 297 | 297 | */ |
| 298 | - public function jsonSerialize (): array { |
|
| 298 | + public function jsonSerialize(): array { |
|
| 299 | 299 | $data = $this->toArray(); |
| 300 | 300 | ksort($data); |
| 301 | 301 | return $data; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param array $query |
| 312 | 312 | * @return null|mixed|AbstractEntity |
| 313 | 313 | */ |
| 314 | - final protected function load (string $class, string $path, array $query = []) { |
|
| 314 | + final protected function load(string $class, string $path, array $query = []) { |
|
| 315 | 315 | return $this->api->load($class, $this, $path, $query); |
| 316 | 316 | } |
| 317 | 317 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param int $pages |
| 327 | 327 | * @return array|AbstractEntity[] |
| 328 | 328 | */ |
| 329 | - final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
| 329 | + final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
| 330 | 330 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -335,8 +335,8 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - public function serialize (): string { |
|
| 339 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
| 338 | + public function serialize(): string { |
|
| 339 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @return array |
| 346 | 346 | */ |
| 347 | - public function toArray (): array { |
|
| 347 | + public function toArray(): array { |
|
| 348 | 348 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
| 349 | 349 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
| 350 | 350 | return $each->getGid(); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * |
| 365 | 365 | * @param $serialized |
| 366 | 366 | */ |
| 367 | - public function unserialize ($serialized): void { |
|
| 367 | + public function unserialize($serialized): void { |
|
| 368 | 368 | $this->api = Api::getDefault(); |
| 369 | 369 | $data = json_decode($serialized, true); |
| 370 | 370 | $this->_setData($data); |
@@ -33,23 +33,23 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | protected $customField; |
| 35 | 35 | |
| 36 | - public function __construct (CustomField $customField, array $data = []) { |
|
| 36 | + public function __construct(CustomField $customField, array $data = []) { |
|
| 37 | 37 | parent::__construct($customField, $data); |
| 38 | 38 | $this->customField = $customField; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - final public function __toString (): string { |
|
| 41 | + final public function __toString(): string { |
|
| 42 | 42 | return "enum_options/{$this->getGid()}"; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - final protected function _getDir (): string { |
|
| 45 | + final protected function _getDir(): string { |
|
| 46 | 46 | return "{$this->customField}/enum_options"; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @return CustomField |
| 51 | 51 | */ |
| 52 | - public function getCustomField () { |
|
| 52 | + public function getCustomField() { |
|
| 53 | 53 | return $this->customField; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param EnumOption $option |
| 59 | 59 | * @return $this |
| 60 | 60 | */ |
| 61 | - public function moveAfter (EnumOption $option) { |
|
| 61 | + public function moveAfter(EnumOption $option) { |
|
| 62 | 62 | $this->api->post("{$this->_getDir()}/insert", [ |
| 63 | 63 | 'after_enum_option' => $option->getGid(), |
| 64 | 64 | 'enum_option' => $this->getGid() |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param EnumOption $option |
| 73 | 73 | * @return $this |
| 74 | 74 | */ |
| 75 | - public function moveBefore (EnumOption $option) { |
|
| 75 | + public function moveBefore(EnumOption $option) { |
|
| 76 | 76 | $this->api->post("{$this->_getDir()}/insert", [ |
| 77 | 77 | 'before_enum_option' => $option->getGid(), |
| 78 | 78 | 'enum_option' => $this->getGid() |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * @return $this |
| 86 | 86 | */ |
| 87 | - public function moveFirst () { |
|
| 87 | + public function moveFirst() { |
|
| 88 | 88 | $first = $this->customField->getEnumOptions()[0]; |
| 89 | 89 | if ($first !== $this) { |
| 90 | 90 | $this->moveBefore($first); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * @return $this |
| 97 | 97 | */ |
| 98 | - public function moveLast () { |
|
| 98 | + public function moveLast() { |
|
| 99 | 99 | $options = $this->customField->getEnumOptions(); |
| 100 | 100 | $last = $options[count($options) - 1]; |
| 101 | 101 | if ($last !== $this) { |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * @param Workspace $workspace |
| 18 | 18 | * @return $this |
| 19 | 19 | */ |
| 20 | - public function setWorkspace (Workspace $workspace) { |
|
| 20 | + public function setWorkspace(Workspace $workspace) { |
|
| 21 | 21 | return $this->{'_set'}('workspace', $workspace); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |