diff --git a/src/Picqer/Financials/Exact/DocumentAttachment.php b/src/Picqer/Financials/Exact/DocumentAttachment.php index 489b667b..099bcd17 100644 --- a/src/Picqer/Financials/Exact/DocumentAttachment.php +++ b/src/Picqer/Financials/Exact/DocumentAttachment.php @@ -1,5 +1,7 @@ Url . '&Download=1'; } diff --git a/src/Picqer/Financials/Exact/Item.php b/src/Picqer/Financials/Exact/Item.php index 2dc3a85f..8a874e4a 100644 --- a/src/Picqer/Financials/Exact/Item.php +++ b/src/Picqer/Financials/Exact/Item.php @@ -1,5 +1,7 @@ PictureUrl; } diff --git a/src/Picqer/Financials/Exact/Model.php b/src/Picqer/Financials/Exact/Model.php index bebad1de..d5ea7f2f 100644 --- a/src/Picqer/Financials/Exact/Model.php +++ b/src/Picqer/Financials/Exact/Model.php @@ -1,5 +1,7 @@ connection; } @@ -56,29 +47,25 @@ public function connection() /** * Get the model's attributes. * - * @return array + * @return array */ - public function attributes() + public function attributes(): array { return $this->attributes; } /** * Get the model's url. - * - * @return string */ - public function url() + public function url(): string { return $this->url; } /** * Get the model's primary key. - * - * @return string */ - public function primaryKey() + public function primaryKey(): string { return $this->primaryKey; } @@ -96,7 +83,7 @@ public function primaryKeyContent() /** * Fill the entity from an array. * - * @param array $attributes + * @param array $attributes */ protected function fill(array $attributes) { @@ -110,9 +97,9 @@ protected function fill(array $attributes) /** * Get the fillable attributes of an array. * - * @param array $attributes + * @param array $attributes * - * @return array + * @return array */ protected function fillableFromArray(array $attributes) { @@ -123,31 +110,30 @@ protected function fillableFromArray(array $attributes) return $attributes; } - protected function isFillable($key) + protected function isFillable($key): bool { return in_array($key, $this->fillable); } - public function getFillable() + /** + * @return array + */ + public function getFillable(): array { return $this->fillable; } - protected function setAttribute($key, $value) + protected function setAttribute($key, $value): void { $this->attributes[$key] = $value; } /** * Resolve deferred values. - * - * @param string $key - * - * @return bool Returns true when collection is found */ - protected function lazyLoad($key) + protected function lazyLoad(string $key): bool { - // Check previously resolved or manualy set. + // Check previously resolved or manually set. if (isset($this->deferred[$key])) { return true; } @@ -170,7 +156,7 @@ protected function lazyLoad($key) return false; } - public function __get($key) + public function __get(string $key) { if ($this->lazyLoad($key)) { return $this->deferred[$key]; @@ -181,7 +167,7 @@ public function __get($key) } } - public function __set($key, $value) + public function __set(string $key, $value) { if ($this->isFillable($key)) { if (is_array($value)) { @@ -194,12 +180,12 @@ public function __set($key, $value) } } - public function __isset($name) + public function __isset(string $name) { return $this->__get($name) !== null; } - public function __call($name, $arguments) + public function __call(string $name, $arguments) { return $this->__get($name); } @@ -220,10 +206,8 @@ public function refresh($key) /** * Checks if primaryKey holds a value. - * - * @return bool */ - public function exists() + public function exists(): bool { if (! array_key_exists($this->primaryKey, $this->attributes)) { return false; @@ -234,12 +218,8 @@ public function exists() /** * Return the JSON representation of the data. - * - * @param int $options http://php.net/manual/en/json.constants.php - * - * @return string */ - public function json($options = 0, $withDeferred = false) + public function json(int $options = 0, bool $withDeferred = false): string { $attributes = $this->attributes; if ($withDeferred) { @@ -269,10 +249,10 @@ public function json($options = 0, $withDeferred = false) /** * Return serializable data. * - * @return array + * @return array */ #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { return $this->attributes; } @@ -280,12 +260,8 @@ public function jsonSerialize() /** * Check whether the current user has rights for an action on this endpoint * https://start.exactonline.nl/docs/HlpRestAPIResources.aspx?SourceAction=10. - * - * @param string $action - * - * @return bool|null */ - public function userHasRights($action = 'GET') + public function userHasRights(string $action = 'GET'): ?bool { $action = preg_match('/^GET|POST|PUT|DELETE$/i', $action) ? strtoupper($action) : 'GET'; $result = $this->connection()->get('users/UserHasRights', [ @@ -293,6 +269,6 @@ public function userHasRights($action = 'GET') 'action' => "'{$action}'", ]); - return isset($result['UserHasRights']) ? $result['UserHasRights'] : null; + return $result['UserHasRights'] ?? null; } } diff --git a/src/Picqer/Financials/Exact/Persistance/Downloadable.php b/src/Picqer/Financials/Exact/Persistance/Downloadable.php index 70748d1c..8bc2dfd2 100644 --- a/src/Picqer/Financials/Exact/Persistance/Downloadable.php +++ b/src/Picqer/Financials/Exact/Persistance/Downloadable.php @@ -4,23 +4,15 @@ use GuzzleHttp\Client; use Picqer\Financials\Exact\Connection; +use Psr\Http\Message\StreamInterface; trait Downloadable { - /** - * @return Connection - */ - abstract public function connection(); - - /** - * @return string - */ - abstract public function getDownloadUrl(); - - /** - * @return mixed Binary representation of file - */ - public function download() + abstract public function connection(): Connection; + + abstract public function getDownloadUrl(): string; + + public function download(): StreamInterface { $client = new Client(); diff --git a/src/Picqer/Financials/Exact/Persistance/Storable.php b/src/Picqer/Financials/Exact/Persistance/Storable.php index 4159e343..3b857b47 100644 --- a/src/Picqer/Financials/Exact/Persistance/Storable.php +++ b/src/Picqer/Financials/Exact/Persistance/Storable.php @@ -1,5 +1,7 @@ $attributes */ abstract protected function fill(array $attributes); - /** - * @param int $options - * @param bool $withDeferred - * - * @return string - */ - abstract public function json($options = 0, $withDeferred = false); + abstract public function json(int $options = 0, bool $withDeferred = false): string; - /** - * @return Connection - */ - abstract public function connection(); + abstract public function connection(): Connection; - /** - * @return string - */ - abstract public function url(); + abstract public function url(): string; /** * @return mixed @@ -45,7 +32,7 @@ abstract public function primaryKeyContent(); * * @return $this */ - public function save() + public function save(): self { if ($this->exists()) { $this->fill($this->update()); diff --git a/src/Picqer/Financials/Exact/Query/Findable.php b/src/Picqer/Financials/Exact/Query/Findable.php index 225eb692..e7f420bf 100644 --- a/src/Picqer/Financials/Exact/Query/Findable.php +++ b/src/Picqer/Financials/Exact/Query/Findable.php @@ -1,5 +1,7 @@ $params */ - public function __construct(Connection $connection, $url, $class, array $params) + public function __construct(Connection $connection, ?string $url, string $class, array $params) { $this->connection = $connection; $this->url = $url; @@ -60,10 +45,7 @@ public function nextAsGenerator(): Generator return $this->collectionFromResultAsGenerator($result); } - /** - * @return bool - */ - public function hasMore() + public function hasMore(): bool { return $this->url !== null; } diff --git a/src/Picqer/Financials/Exact/Webhook/Authenticatable.php b/src/Picqer/Financials/Exact/Webhook/Authenticatable.php index 7b08111b..9e514dbe 100755 --- a/src/Picqer/Financials/Exact/Webhook/Authenticatable.php +++ b/src/Picqer/Financials/Exact/Webhook/Authenticatable.php @@ -1,10 +1,12 @@