diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c1dd94..fa0e567 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: true matrix: - php: [7.2, 7.3, 7.4] + php: [8.1, 8.2] stability: [prefer-lowest, prefer-stable] name: PHP ${{ matrix.php }} - ${{ matrix.stability }} @@ -20,6 +20,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + # Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents. If you use a shallow git checkout, please checkout at least a depth of one."), see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository + # 10 commits is an arbitrary value that is more than 1 commit + fetch-depth: 10 - name: Cache dependencies uses: actions/cache@v1 @@ -34,16 +38,14 @@ jobs: coverage: pcov - name: Install dependencies - run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest - name: PHP Security Checker - uses: symfonycorp/security-checker-action@v2 - with: - disable-exit-code: 1 + uses: symfonycorp/security-checker-action@v5 if: ${{ matrix.stability == 'prefer-stable' }} - name: Execute tests run: vendor/bin/phpunit --coverage-clover=coverage.clover --verbose - name: Upload Code Coverage - run: wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover + run: vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover diff --git a/.gitignore b/.gitignore index a039820..cc4a632 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ /node_modules phpunit.xml /build +.env .phpunit.result.cache composer.lock diff --git a/VERSION b/VERSION index db6fb4a..f0bb29e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.8 +1.3.0 diff --git a/composer.json b/composer.json index d44cf29..84732df 100644 --- a/composer.json +++ b/composer.json @@ -19,17 +19,19 @@ } ], "require": { - "php": ">=7.2", + "php": "^8.0.2", "ext-json": "*", - "guzzlehttp/guzzle": "^6.4|^7.0", - "laravel/framework": "~5.8|~6|~7|~8", - "nesbot/carbon": "~1.2|~2" + "guzzlehttp/guzzle": "^7.0", + "laravel/framework": "^9.19|^10", + "nesbot/carbon": "^2.62.1" }, "require-dev": { - "mockery/mockery": "^1.3.1", - "phpunit/phpunit": "^8.4|^9.0", - "psy/psysh": "^0.10", - "symfony/thanks": "^1.1" + "laravel/pint": "^1.4", + "mockery/mockery": "^1.5.1", + "phpunit/phpunit": "^9.5.8", + "psy/psysh": "^0.11", + "scrutinizer/ocular": "^1.9", + "squizlabs/php_codesniffer": "^3.7" }, "autoload": { "psr-4": { diff --git a/config/clickup.php b/config/clickup.php index bc41782..7b31804 100644 --- a/config/clickup.php +++ b/config/clickup.php @@ -11,11 +11,11 @@ | */ 'oauth' => [ - 'id' => env('CLICKUP_CLIENT_ID'), + 'id' => env('CLICKUP_CLIENT_ID'), 'secret' => env('CLICKUP_CLIENT_SECRET'), - 'url' => env('CLICKUP_OAUTH_URL', 'https://app.clickup.com/api'), + 'url' => env('CLICKUP_OAUTH_URL', 'https://app.clickup.com/api'), ], /* @@ -27,11 +27,11 @@ | */ 'route' => [ - 'enabled' => true, + 'enabled' => true, 'middleware' => ['web'], - 'sso' => 'clickup/sso', + 'sso' => 'clickup/sso', ], /* diff --git a/database/migrations/2019_09_23_194855_add_click_up_token_to_users_table.php b/database/migrations/2019_09_23_194855_add_click_up_token_to_users_table.php index ef16d2a..1eb8942 100644 --- a/database/migrations/2019_09_23_194855_add_click_up_token_to_users_table.php +++ b/database/migrations/2019_09_23_194855_add_click_up_token_to_users_table.php @@ -2,7 +2,9 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Schema\ColumnDefinition; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Fluent; /** * Class AddClickUpTokenToUsersTable @@ -20,11 +22,9 @@ public function up() { Schema::table( 'users', - function (Blueprint $table) { - $table->string('clickup_token', 1024) + fn (Blueprint $table): ColumnDefinition => $table->string('clickup_token', 1024) ->after('password') - ->nullable(); - } + ->nullable() ); } @@ -37,9 +37,7 @@ public function down() { Schema::table( 'users', - function (Blueprint $table) { - $table->dropColumn('clickup_token'); - } + fn (Blueprint $table): Fluent => $table->dropColumn('clickup_token') ); } } diff --git a/nitpick.json b/nitpick.json deleted file mode 100644 index d527ec8..0000000 --- a/nitpick.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "ignore": [ - "tests/*", - "generator/*" - ] -} diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..7e265ca --- /dev/null +++ b/pint.json @@ -0,0 +1,6 @@ +{ + "preset": "laravel", + "rules": { + "no_superfluous_phpdoc_tags": true + } +} diff --git a/routes/web.php b/routes/web.php index 6bf7623..698d08f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,5 +3,5 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Route; -Route::get(rtrim(Config::get('clickup.route.sso', '/clickup/sso'), '/') . '/{user}', 'ClickUpController@processCode') +Route::get(rtrim(Config::get('clickup.route.sso', '/clickup/sso'), '/').'/{user}', 'ClickUpController@processCode') ->name('clickup.sso.redirect_url'); diff --git a/src/Api/Client.php b/src/Api/Client.php index 2deb1ff..e671c35 100644 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -9,40 +9,28 @@ /** * Class Client - * - * @package Spinen\ClickUp */ class Client { /** * Configs for the client - * - * @var array */ - protected $configs; + protected array $configs; /** * Guzzle instance - * - * @var Guzzle */ - protected $guzzle; + protected Guzzle $guzzle; /** * API Token - * - * @var string */ - protected $token; + protected ?string $token; /** * Client constructor. - * - * @param array $configs - * @param Guzzle $guzzle - * @param string|null $token */ - public function __construct(array $configs, Guzzle $guzzle, $token = null) + public function __construct(array $configs, Guzzle $guzzle, ?string $token = null) { $this->setConfigs($configs); $this->guzzle = $guzzle; @@ -52,13 +40,10 @@ public function __construct(array $configs, Guzzle $guzzle, $token = null) /** * Shortcut to 'DELETE' request * - * @param string $path - * - * @return array|null * @throws GuzzleException * @throws TokenException */ - public function delete($path): ?array + public function delete(string $path): ?array { return $this->request($path, [], 'DELETE'); } @@ -66,13 +51,10 @@ public function delete($path): ?array /** * Shortcut to 'GET' request * - * @param string $path - * - * @return array|null * @throws GuzzleException * @throws TokenException */ - public function get($path): ?array + public function get(string $path): ?array { return $this->request($path, [], 'GET'); } @@ -80,18 +62,15 @@ public function get($path): ?array /** * Convert OAuth code to token for user * - * @param string $code - * - * @return string * @throws GuzzleException */ - public function oauthRequestTokenUsingCode($code): string + public function oauthRequestTokenUsingCode(string $code): string { - $path = 'oauth/token?' . http_build_query( + $path = 'oauth/token?'.http_build_query( [ - 'client_id' => $this->configs['oauth']['id'], + 'client_id' => $this->configs['oauth']['id'], 'client_secret' => $this->configs['oauth']['secret'], - 'code' => $code, + 'code' => $code, ] ); @@ -102,7 +81,7 @@ public function oauthRequestTokenUsingCode($code): string $this->uri($path), [ 'headers' => [ - 'Content-Type' => 'application/json', + 'Content-Type' => 'application/json', ], ] ) @@ -120,17 +99,13 @@ public function oauthRequestTokenUsingCode($code): string /** * Build the uri to redirect the user to start the OAuth process - * - * @param string $url - * - * @return string */ - public function oauthUri($url): string + public function oauthUri(string $url): string { return $this->uri( - '?' . http_build_query( + '?'.http_build_query( [ - 'client_id' => $this->configs['oauth']['id'], + 'client_id' => $this->configs['oauth']['id'], 'redirect_uri' => $url, ] ), @@ -141,14 +116,10 @@ public function oauthUri($url): string /** * Shortcut to 'POST' request * - * @param string $path - * @param array $data - * - * @return array|null * @throws GuzzleException * @throws TokenException */ - public function post($path, array $data): ?array + public function post(string $path, array $data): ?array { return $this->request($path, $data, 'POST'); } @@ -156,14 +127,10 @@ public function post($path, array $data): ?array /** * Shortcut to 'PUT' request * - * @param string $path - * @param array $data - * - * @return array|null * @throws GuzzleException * @throws TokenException */ - public function put($path, array $data): ?array + public function put(string $path, array $data): ?array { return $this->request($path, $data, 'PUT'); } @@ -171,17 +138,12 @@ public function put($path, array $data): ?array /** * Make an API call to ClickUp * - * @param string $path - * @param array|null $data - * @param string|null $method - * - * @return array|null * @throws GuzzleException * @throws TokenException */ - public function request($path, $data = [], $method = 'GET'): ?array + public function request(?string $path, ?array $data = [], ?string $method = 'GET'): ?array { - if (!$this->token) { + if (! $this->token) { throw new TokenException('Must set token before making a request'); } @@ -193,9 +155,9 @@ public function request($path, $data = [], $method = 'GET'): ?array [ 'headers' => [ 'Authorization' => $this->token, - 'Content-Type' => 'application/json', + 'Content-Type' => 'application/json', ], - 'body' => empty($data) ? null : json_encode($data), + 'body' => empty($data) ? null : json_encode($data), ] ) ->getBody() @@ -212,29 +174,19 @@ public function request($path, $data = [], $method = 'GET'): ?array /** * Set the configs - * - * @param array $configs - * - * @return $this */ public function setConfigs(array $configs): self { // Replace empty strings with nulls in config values - $this->configs = array_map(function($value) { - return $value === "" ? null : $value; - }, $configs); + $this->configs = array_map(fn ($v) => $v === '' ? null : $v, $configs); return $this; } /** * Set the token - * - * @param string $token - * - * @return $this */ - public function setToken($token): self + public function setToken(?string $token): self { $this->token = $token; @@ -247,16 +199,12 @@ public function setToken($token): self * If path is passed in, then append it to the end. By default, it will use the url * in the configs, but if a url is passed in as a second parameter then it is used. * If no url is found it will use the hard-coded v2 ClickUp API URL. - * - * @param string|null $path - * @param string|null $url - * - * @return string */ - public function uri($path = null, $url = null): string + public function uri(?string $path = null, ?string $url = null): string { - $url = $url ?? $this->configs['url'] ?? 'https://api.clickup.com/api/v2'; + $path = ltrim($path ?? '/', '/'); - return rtrim($url, '/') . (Str::startsWith($path, '?') ? null : '/') . ltrim($path, '/'); + return rtrim($url ?? $this->configs['url'] ?? 'https://api.clickup.com/api/v2', '/') + .($path ? (Str::startsWith($path, '?') ? null : '/').$path : '/'); } } diff --git a/src/Checklist.php b/src/Checklist.php index 8ef2786..6d21054 100644 --- a/src/Checklist.php +++ b/src/Checklist.php @@ -13,10 +13,8 @@ /** * Class Checklist * - * @package Spinen\ClickUp - * - * @property boolean $resolved - * @property boolean $unresolved + * @property bool $resolved + * @property bool $unresolved * @property Carbon $date_created * @property Collection $items * @property float $orderindex @@ -34,26 +32,21 @@ class Checklist extends Model */ protected $casts = [ 'date_created' => 'datetime:Uv', - 'id' => 'string', - 'orderindex' => 'float', - 'resolved' => 'boolean', - 'task_id' => 'string', - 'unresolved' => 'boolean', + 'id' => 'string', + 'orderindex' => 'float', + 'resolved' => 'boolean', + 'task_id' => 'string', + 'unresolved' => 'boolean', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/checklist'; + protected string $path = '/checklist'; /** * Accessor for Items. * - * @param array $items - * - * @return Collection * @throws NoClientException */ public function getItemsAttribute(array $items): Collection @@ -62,7 +55,8 @@ public function getItemsAttribute(array $items): Collection } /** - * @return ChildOf + * Child of Task + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Comment.php b/src/Comment.php index 27944a4..8244597 100644 --- a/src/Comment.php +++ b/src/Comment.php @@ -12,18 +12,19 @@ /** * Class Comment * - * @package Spinen\ClickUp - * * @property array $comments * @property array $relations - * @property boolean $resolved + * @property bool $resolved * @property Carbon $date - * @property integer $id + * @property int $id * @property Member $assigned_by * @property Member $assignee * @property Member $user * @property string $hist_id * @property string $text + * @property Task|null $task + * @property TasksList|null $list + * @property View|null $view */ class Comment extends Model { @@ -33,27 +34,22 @@ class Comment extends Model * @var array */ protected $casts = [ - 'date' => 'datetime:Uv', - 'id' => 'integer', + 'date' => 'datetime:Uv', + 'id' => 'integer', 'resolved' => 'boolean', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/comment'; + protected string $path = '/comment'; /** * Accessor for Assignee. * - * @param array $assignee - * - * @return Member * @throws NoClientException */ - public function getAssigneeAttribute($assignee): Member + public function getAssigneeAttribute(?array $assignee): Member { return $this->givenOne(Member::class, $assignee); } @@ -61,12 +57,9 @@ public function getAssigneeAttribute($assignee): Member /** * Accessor for AssignedBy. * - * @param array $assigned_by - * - * @return Member * @throws NoClientException */ - public function getAssignedByAttribute($assigned_by): Member + public function getAssignedByAttribute(?array $assigned_by): Member { return $this->givenOne(Member::class, $assigned_by); } @@ -74,18 +67,16 @@ public function getAssignedByAttribute($assigned_by): Member /** * Accessor for User. * - * @param array $user - * - * @return Member * @throws NoClientException */ - public function getUserAttribute($user): Member + public function getUserAttribute(?array $user): Member { return $this->givenOne(Member::class, $user); } /** - * @return ChildOf + * Optional Child of TaskList + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -96,7 +87,8 @@ public function list(): ?ChildOf } /** - * @return ChildOf + * Child of Task + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -107,7 +99,8 @@ public function task(): ?ChildOf } /** - * @return ChildOf + * Child of View + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Concerns/HasClickUp.php b/src/Concerns/HasClickUp.php index 2169d16..794e872 100644 --- a/src/Concerns/HasClickUp.php +++ b/src/Concerns/HasClickUp.php @@ -4,7 +4,7 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Container\BindingResolutionException; -use Illuminate\Contracts\Encryption\Encrypter; +use Illuminate\Support\Facades\Crypt; use Spinen\ClickUp\Api\Client as ClickUp; use Spinen\ClickUp\Exceptions\NoClientException; use Spinen\ClickUp\Support\Builder; @@ -12,8 +12,6 @@ /** * Trait HasClickUp * - * @package Spinen\ClickUp - * * @property ClickUp $clickup * @property string $clickup_token */ @@ -21,27 +19,24 @@ trait HasClickUp { /** * ClickUp Builder instance - * - * @var Builder */ - protected $builder = null; + protected ?Builder $builder = null; /** * Return cached version of the ClickUp Builder for the user * - * @return Builder * @throws BindingResolutionException */ - public function clickup() + public function clickup(): Builder { if (is_null($this->builder)) { $this->builder = Container::getInstance() - ->make(Builder::class) - ->setClient( - Container::getInstance() - ->make(ClickUp::class) - ->setToken($this->clickup_token) - ); + ->make(Builder::class) + ->setClient( + Container::getInstance() + ->make(ClickUp::class) + ->setToken($this->clickup_token) + ); } return $this->builder; @@ -50,27 +45,24 @@ public function clickup() /** * Accessor for ClickUp Client. * - * @return ClickUp * @throws BindingResolutionException * @throws NoClientException */ - public function getClickupAttribute() + public function getClickupAttribute(): ClickUp { return $this->clickup() - ->getClient(); + ->getClient(); } /** * Accessor for ClickUpToken. * * @throws BindingResolutionException - * @return string|null */ - public function getClickupTokenAttribute() + public function getClickupTokenAttribute(): ?string { - if (!is_null($this->attributes['clickup_token'])) { - return $this->resolveEncrypter() - ->decrypt($this->attributes['clickup_token']); + if (! is_null($this->attributes['clickup_token'])) { + return Crypt::decryptString($this->attributes['clickup_token']); } return null; @@ -79,43 +71,27 @@ public function getClickupTokenAttribute() /** * Make sure that the clickup_token is fillable & protected */ - public function initializeHasClickUp() + public function initializeHasClickUp(): void { $this->fillable[] = 'clickup_token'; $this->hidden[] = 'clickup'; $this->hidden[] = 'clickup_token'; } - /** - * Resolve the encrypter from the IoC - * - * We are staying away from the Crypt facade, so that we can support PHP 7.4 with Laravel 5.x - * - * @return Encrypter - * @throws BindingResolutionException - */ - protected function resolveEncrypter() - { - return Container::getInstance() - ->make(Encrypter::class); - } - /** * Mutator for ClickUpToken. * - * @param string $clickup_token * @throws BindingResolutionException */ - public function setClickupTokenAttribute($clickup_token) + public function setClickupTokenAttribute(?string $clickup_token): void { // If setting the password & already have a client, then empty the client to use new password in client - if (!is_null($this->builder)) { + if (! is_null($this->builder)) { $this->builder = null; } $this->attributes['clickup_token'] = is_null($clickup_token) ? null - : $this->resolveEncrypter() - ->encrypt($clickup_token); + : Crypt::encryptString($clickup_token); } } diff --git a/src/Concerns/HasClient.php b/src/Concerns/HasClient.php index 1c1e675..cf3f608 100644 --- a/src/Concerns/HasClient.php +++ b/src/Concerns/HasClient.php @@ -4,32 +4,28 @@ use Spinen\ClickUp\Api\Client; use Spinen\ClickUp\Exceptions\NoClientException; -use Spinen\ClickUp\Support\Model; trait HasClient { /** * Client instance - * - * @var Client */ - protected $client; + protected Client $client; /** * Get the Client instance * * If there is no client assigned on the model, but it has a parent, then try to get the parent's client * - * @return Client * @throws NoClientException */ public function getClient(): Client { - if (!$this->client && $this->parentModel) { + if (! isset($this->client) && $this->parentModel) { $this->client = $this->parentModel->getClient(); } - if ($this->client) { + if (isset($this->client)) { return $this->client; } @@ -38,10 +34,6 @@ public function getClient(): Client /** * Set the client instance - * - * @param Client $client - * - * @return $this */ public function setClient(?Client $client): self { diff --git a/src/Exceptions/InvalidQueryException.php b/src/Exceptions/InvalidQueryException.php index a6b2281..29844ff 100644 --- a/src/Exceptions/InvalidQueryException.php +++ b/src/Exceptions/InvalidQueryException.php @@ -6,5 +6,4 @@ class InvalidQueryException extends Exception { - } diff --git a/src/Exceptions/InvalidRelationshipException.php b/src/Exceptions/InvalidRelationshipException.php index af4dfb2..30e1b07 100644 --- a/src/Exceptions/InvalidRelationshipException.php +++ b/src/Exceptions/InvalidRelationshipException.php @@ -6,5 +6,4 @@ class InvalidRelationshipException extends Exception { - } diff --git a/src/Exceptions/ModelNotFoundException.php b/src/Exceptions/ModelNotFoundException.php index 5d08698..d3ce33a 100644 --- a/src/Exceptions/ModelNotFoundException.php +++ b/src/Exceptions/ModelNotFoundException.php @@ -6,5 +6,4 @@ class ModelNotFoundException extends Exception { - } diff --git a/src/Exceptions/ModelReadonlyException.php b/src/Exceptions/ModelReadonlyException.php index 5630cc9..66e0d75 100644 --- a/src/Exceptions/ModelReadonlyException.php +++ b/src/Exceptions/ModelReadonlyException.php @@ -6,5 +6,4 @@ class ModelReadonlyException extends Exception { - } diff --git a/src/Exceptions/NoClientException.php b/src/Exceptions/NoClientException.php index 676eac8..45f72bb 100644 --- a/src/Exceptions/NoClientException.php +++ b/src/Exceptions/NoClientException.php @@ -6,5 +6,4 @@ class NoClientException extends Exception { - } diff --git a/src/Exceptions/TokenException.php b/src/Exceptions/TokenException.php index 5f2fe04..707ca08 100644 --- a/src/Exceptions/TokenException.php +++ b/src/Exceptions/TokenException.php @@ -6,5 +6,4 @@ class TokenException extends Exception { - } diff --git a/src/Exceptions/UnableToSaveException.php b/src/Exceptions/UnableToSaveException.php index 79b21e8..3b91bec 100644 --- a/src/Exceptions/UnableToSaveException.php +++ b/src/Exceptions/UnableToSaveException.php @@ -6,5 +6,4 @@ class UnableToSaveException extends Exception { - } diff --git a/src/Exceptions/UserException.php b/src/Exceptions/UserException.php index 6ce9268..3554046 100644 --- a/src/Exceptions/UserException.php +++ b/src/Exceptions/UserException.php @@ -6,5 +6,4 @@ class UserException extends Exception { - } diff --git a/src/Field.php b/src/Field.php index 759b35d..708dcac 100644 --- a/src/Field.php +++ b/src/Field.php @@ -12,10 +12,8 @@ /** * Class Field * - * @package Spinen\ClickUp - * * @property array $type_config - * @property boolean $hide_from_guests + * @property bool $hide_from_guests * @property Carbon $date_created * @property string $id * @property string $name @@ -30,9 +28,9 @@ class Field extends Model * @var array */ protected $casts = [ - 'date_created' => 'datetime:Uv', + 'date_created' => 'datetime:Uv', 'hide_from_guest' => 'boolean', - 'id' => 'string', + 'id' => 'string', ]; /** @@ -41,20 +39,17 @@ class Field extends Model * Several of the endpoints are nested behind another model for relationship, but then to * interact with the specific model, then are not nested. This property will know when to * keep the specific model nested. - * - * @var bool */ - protected $nested = true; + protected bool $nested = true; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/field'; + protected string $path = '/field'; /** - * @return ChildOf + * Child of TaskList + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Folder.php b/src/Folder.php index a32013f..e1a02d4 100644 --- a/src/Folder.php +++ b/src/Folder.php @@ -13,17 +13,15 @@ /** * Class Folder * - * @package Spinen\ClickUp - * - * @property boolean $archived - * @property boolean $hidden - * @property boolean $override_statuses + * @property bool $archived + * @property bool $hidden + * @property bool $override_statuses * @property Collection $lists * @property Collection $statuses * @property Collection $views * @property float $orderindex - * @property integer $id - * @property integer $task_count + * @property int $id + * @property int $task_count * @property Space $space * @property string $name */ @@ -35,30 +33,25 @@ class Folder extends Model * @var array */ protected $casts = [ - 'archived' => 'boolean', - 'hidden' => 'boolean', - 'id' => 'integer', - 'orderindex' => 'float', + 'archived' => 'boolean', + 'hidden' => 'boolean', + 'id' => 'integer', + 'orderindex' => 'float', 'override_statuses' => 'boolean', - 'task_count' => 'integer', + 'task_count' => 'integer', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/folder'; + protected string $path = '/folder'; /** * Accessor for Statuses. * - * @param array $statuses - * - * @return Collection * @throws NoClientException */ - public function getStatusesAttribute(array $statuses): Collection + public function getStatusesAttribute(?array $statuses): Collection { return $this->givenMany(Status::class, $statuses); } @@ -66,18 +59,16 @@ public function getStatusesAttribute(array $statuses): Collection /** * Accessor for Lists. * - * @param array $lists - * - * @return Collection * @throws NoClientException */ - public function getListsAttribute(array $lists): Collection + public function getListsAttribute(?array $lists): Collection { return $this->givenMany(TaskList::class, $lists); } /** - * @return ChildOf + * Child of Space + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -88,8 +79,8 @@ public function space(): ChildOf } /** - * @return HasMany - + * HasMany Views + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Goal.php b/src/Goal.php index 10cb414..642bb1f 100644 --- a/src/Goal.php +++ b/src/Goal.php @@ -14,15 +14,13 @@ /** * Class Goal * - * @package Spinen\ClickUp - * * @property array $history * @property array $key_results * @property array $reactions - * @property boolean $archived - * @property boolean $multiple_owners - * @property boolean $pinned - * @property boolean $private + * @property bool $archived + * @property bool $multiple_owners + * @property bool $pinned + * @property bool $private * @property Carbon $date_created * @property Carbon $due_date * @property Carbon $last_update @@ -31,12 +29,12 @@ * @property Collection $owners * @property float $percent_completed * @property Folder $folder - * @property integer $creator - * @property integer $folder_id - * @property integer $key_result_count - * @property integer $owner - * @property integer $pretty_id - * @property integer $team_id + * @property int $creator + * @property int $folder_id + * @property int $key_result_count + * @property int $owner + * @property int $pretty_id + * @property int $team_id * @property string $color * @property string $description * @property string $id @@ -51,61 +49,54 @@ class Goal extends Model * @var array */ protected $casts = [ - 'archived' => 'boolean', - 'creator' => 'integer', - 'date_created' => 'datetime:Uv', - 'due_date' => 'datetime:Uv', - 'folder_id' => 'integer', - 'id' => 'string', - 'key_result_count' => 'integer', - 'last_update' => 'datetime:Uv', - 'multiple_owners' => 'boolean', - 'owner' => 'integer', + 'archived' => 'boolean', + 'creator' => 'integer', + 'date_created' => 'datetime:Uv', + 'due_date' => 'datetime:Uv', + 'folder_id' => 'integer', + 'id' => 'string', + 'key_result_count' => 'integer', + 'last_update' => 'datetime:Uv', + 'multiple_owners' => 'boolean', + 'owner' => 'integer', 'percent_completed' => 'float', - 'pinned' => 'boolean', - 'pretty_id' => 'integer', - 'private' => 'boolean', - 'start_date' => 'datetime:Uv', - 'team_id' => 'integer', + 'pinned' => 'boolean', + 'pretty_id' => 'integer', + 'private' => 'boolean', + 'start_date' => 'datetime:Uv', + 'team_id' => 'integer', ]; // TODO: Setup creator & owner as a "BelongsTo" (need API resource to look up a Member) /** * Path to API endpoint. - * - * @var string */ - protected $path = '/goal'; + protected string $path = '/goal'; /** - * Accessor for Owners. - * - * @param array $owners + * Accessor for Members. * - * @return Collection * @throws NoClientException */ - public function getOwnersAttribute(array $owners): Collection + public function getMembersAttribute(?array $members): Collection { - return $this->givenMany(Member::class, $owners); + return $this->givenMany(Member::class, $members, true); } /** - * Accessor for Members. - * - * @param array $members + * Accessor for Owners. * - * @return Collection * @throws NoClientException */ - public function getMembersAttribute(array $members): Collection + public function getOwnersAttribute(?array $owners): Collection { - return $this->givenMany(Member::class, $members, true); + return $this->givenMany(Member::class, $owners); } /** - * @return BelongsTo + * Belongs to Folder + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -116,7 +107,8 @@ public function folder(): BelongsTo } /** - * @return ChildOf + * Child of Team + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Http/Controllers/ClickUpController.php b/src/Http/Controllers/ClickUpController.php index f5c83e5..1fc0ee5 100644 --- a/src/Http/Controllers/ClickUpController.php +++ b/src/Http/Controllers/ClickUpController.php @@ -12,25 +12,18 @@ /** * Class ClickUpController - * - * @package Spinen\ClickUp\Http\Controllers */ class ClickUpController extends Controller { /** * Process the code returned for the user & save as clickup_token * - * @param ClickUp $clickup - * @param Redirector $redirector - * @param Request $request - * @param User $user - * - * @return RedirectResponse * @throws GuzzleException */ - public function processCode(ClickUp $clickup, Redirector $redirector, Request $request, User $user) + public function processCode(ClickUp $clickup, Redirector $redirector, Request $request, User $user): RedirectResponse { - $user->clickup_token = $clickup->oauthRequestTokenUsingCode($request->get('code')); + // TODO: Deal with empty code + $user->clickup_token = $clickup->oauthRequestTokenUsingCode((string) $request->get('code')); $user->save(); diff --git a/src/Http/Middleware/Filter.php b/src/Http/Middleware/Filter.php index a68bd28..be8fa9e 100644 --- a/src/Http/Middleware/Filter.php +++ b/src/Http/Middleware/Filter.php @@ -10,62 +10,30 @@ /** * Class Filter - * - * @package Spinen\ClickUp\Http\Middleware */ class Filter { - /** - * The ClickUp client instance. - * - * @var ClickUp - */ - protected $clickup; - - /** - * The redirector instance. - * - * @var Redirector - */ - protected $redirector; - - /** - * The UrlGenerator instance. - * - * @var UrlGenerator - */ - protected $url_generator; - /** * Create a new ClickUp filter middleware instance. - * - * @param ClickUp $clickup - * @param Redirector $redirector - * @param UrlGenerator $url_generator */ - public function __construct(ClickUp $clickup, Redirector $redirector, UrlGenerator $url_generator) - { - $this->clickup = $clickup; - $this->redirector = $redirector; - $this->url_generator = $url_generator; + public function __construct( + protected ClickUp $clickup, + protected Redirector $redirector, + protected UrlGenerator $url_generator + ) { } /** * Handle an incoming request. - * - * @param Request $request Request - * @param Closure $next Closure - * - * @return mixed */ public function handle(Request $request, Closure $next) { - if (!$request->user()->clickup_token) { + if (! $request->user()->clickup_token) { // Set intended route, so that after linking account, user is put where they were going $this->redirector->setIntendedUrl($request->path()); return $this->redirector->to( - $this->clickup->oauthUri($this->url_generator->route('clickup.sso.redirect_url', $request->user())) + $this->clickup->oauthUri((string) $this->url_generator->route('clickup.sso.redirect_url', $request->user())) ); } diff --git a/src/Interval.php b/src/Interval.php index ac61a5e..7f97e2b 100644 --- a/src/Interval.php +++ b/src/Interval.php @@ -12,12 +12,10 @@ /** * Class Interval * - * @package Spinen\ClickUp - * * @property Carbon $date_added * @property Carbon $end * @property Carbon $start - * @property integer $time + * @property int $time * @property string $id * @property string $source * @property Task $task @@ -31,15 +29,16 @@ class Interval extends Model */ protected $casts = [ 'date_added' => 'datetime:Uv', - 'end' => 'datetime:Uv', - 'id' => 'string', - 'start' => 'datetime:Uv', - 'time' => 'integer', + 'end' => 'datetime:Uv', + 'id' => 'string', + 'start' => 'datetime:Uv', + 'time' => 'integer', ]; // TODO: Figure out how to setup relation to task /** - * @return ChildOf + * Child of Task + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Item.php b/src/Item.php index 220c3df..1d64ee3 100644 --- a/src/Item.php +++ b/src/Item.php @@ -10,10 +10,8 @@ /** * Class Item * - * @package Spinen\ClickUp - * - * @property boolean $resolved - * @property boolean $unresolved + * @property bool $resolved + * @property bool $unresolved * @property Carbon $date_created * @property Collection $children * @property float $orderindex @@ -31,10 +29,10 @@ class Item extends Model */ protected $casts = [ 'date_created' => 'datetime:Uv', - 'id' => 'string', - 'orderindex' => 'float', - 'resolved' => 'boolean', - 'unresolved' => 'boolean', + 'id' => 'string', + 'orderindex' => 'float', + 'resolved' => 'boolean', + 'unresolved' => 'boolean', ]; /** @@ -43,27 +41,20 @@ class Item extends Model * Several of the endpoints are nested behind another model for relationship, but then to * interact with the specific model, then are not nested. This property will know when to * keep the specific model nested. - * - * @var bool */ - protected $nested = true; + protected bool $nested = true; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/checklist_item'; + protected string $path = '/checklist_item'; /** * Accessor for Assignee. * - * @param array $assignee - * - * @return Member * @throws NoClientException */ - public function getAssigneeAttribute($assignee): Member + public function getAssigneeAttribute(?array $assignee): Member { return $this->givenOne(Member::class, $assignee); } @@ -71,25 +62,18 @@ public function getAssigneeAttribute($assignee): Member /** * Accessor for Children. * - * @param array $children - * - * @return Collection * @throws NoClientException */ - public function getChildrenAttribute(array $children): Collection + public function getChildrenAttribute(?array $children): Collection { return $this->givenMany(Item::class, $children); } /** * Accessor for Parent. - * - * @param string $parent - * - * @return Item */ // TODO: Figure out how to make this relationship work - /*public function getParentAttribute($parent): Item + /*public function getParentAttribute(string $parent): Item { return $this->parentModel; }*/ diff --git a/src/Member.php b/src/Member.php index ce0a96a..2867aa6 100644 --- a/src/Member.php +++ b/src/Member.php @@ -11,17 +11,15 @@ /** * Class Member * - * @package Spinen\ClickUp - * - * @property integer $id - * @property integer $role + * @property int $id + * @property int $role * @property string $color * @property string $email * @property string $initials * @property string $profilePicture * @property string $username - * @property Task $task - * @property TaskList $list + * @property Task|null $task + * @property TaskList|null $list */ class Member extends Model { @@ -31,19 +29,18 @@ class Member extends Model * @var array */ protected $casts = [ - 'id' => 'integer', + 'id' => 'integer', 'role' => 'integer', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/member'; + protected string $path = '/member'; /** - * @return ChildOf + * Optional Child of TaskList + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -54,7 +51,8 @@ public function list(): ?ChildOf } /** - * @return ChildOf + * Optional Child of Task + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Priority.php b/src/Priority.php index bf5fc26..0fe4d77 100644 --- a/src/Priority.php +++ b/src/Priority.php @@ -7,9 +7,7 @@ /** * Class Priority * - * @package Spinen\ClickUp - * - * @property integer $id + * @property int $id * @property string $priority * @property string $color * @property float $orderindex @@ -22,14 +20,12 @@ class Priority extends Model * @var array */ protected $casts = [ - 'id' => 'integer', + 'id' => 'integer', 'orderindex' => 'float', ]; /** * Is the model readonly? - * - * @var bool */ - protected $readonlyModel = true; + protected bool $readonlyModel = true; } diff --git a/src/Project.php b/src/Project.php index b7bca82..5e3f853 100644 --- a/src/Project.php +++ b/src/Project.php @@ -7,12 +7,10 @@ /** * Class Project * - * @package Spinen\ClickUp - * - * @property integer $id + * @property int $id * @property string $name - * @property boolean $hidden - * @property boolean $access + * @property bool $hidden + * @property bool $access */ class Project extends Model { @@ -22,15 +20,13 @@ class Project extends Model * @var array */ protected $casts = [ - 'id' => 'integer', + 'id' => 'integer', 'hidden' => 'boolean', 'access' => 'boolean', ]; /** * Is the model readonly? - * - * @var bool */ - protected $readonlyModel = true; + protected bool $readonlyModel = true; } diff --git a/src/Providers/ClientServiceProvider.php b/src/Providers/ClientServiceProvider.php index 4e0cf5b..618fd32 100644 --- a/src/Providers/ClientServiceProvider.php +++ b/src/Providers/ClientServiceProvider.php @@ -14,8 +14,6 @@ * Class ClientServiceProvider * * Since this is deferred, it only needed to deal with code that has to do with the client. - * - * @package Spinen\ClickUp\Providers */ class ClientServiceProvider extends LaravelServiceProvider implements DeferrableProvider { @@ -63,16 +61,12 @@ protected function registerClient(): void { $this->app->bind( Builder::class, - function (Application $app) { - return new Builder($app->make(ClickUp::class)); - } + fn (Application $app): Builder => new Builder($app->make(ClickUp::class)) ); $this->app->bind( ClickUp::class, - function (Application $app) { - return new ClickUp(Config::get('clickup'), $app->make(Guzzle::class)); - } + fn (Application $app): ClickUp => new ClickUp(Config::get('clickup'), $app->make(Guzzle::class)) ); } } diff --git a/src/Providers/ServiceProvider.php b/src/Providers/ServiceProvider.php index 27e94f2..8ef4720 100644 --- a/src/Providers/ServiceProvider.php +++ b/src/Providers/ServiceProvider.php @@ -9,8 +9,6 @@ /** * Class ServiceProvider - * - * @package Spinen\ClickUp\Providers */ class ServiceProvider extends LaravelServiceProvider { @@ -35,14 +33,13 @@ public function boot() */ public function register() { - $this->mergeConfigFrom(__DIR__ . '/../../config/clickup.php', 'clickup'); + $this->mergeConfigFrom(__DIR__.'/../../config/clickup.php', 'clickup'); } /** * Register the middleware * * If a route needs to have the QuickBooks client, then make sure that the user has linked their account. - * */ public function registerMiddleware() { @@ -57,18 +54,18 @@ public function registerMiddleware() protected function registerPublishes() { if ($this->app->runningInConsole()) { - $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); + $this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); $this->publishes( [ - __DIR__ . '/../../config/clickup.php' => config_path('clickup.php'), + __DIR__.'/../../config/clickup.php' => config_path('clickup.php'), ], 'clickup-config' ); $this->publishes( [ - __DIR__ . '/../../database/migrations' => database_path('migrations'), + __DIR__.'/../../database/migrations' => database_path('migrations'), ], 'clickup-migrations' ); @@ -83,12 +80,10 @@ protected function registerRoutes() if (Config::get('clickup.route.enabled')) { Route::group( [ - 'namespace' => 'Spinen\ClickUp\Http\Controllers', + 'namespace' => 'Spinen\ClickUp\Http\Controllers', 'middleware' => Config::get('clickup.route.middleware', ['web']), ], - function () { - $this->loadRoutesFrom(realpath(__DIR__ . '/../../routes/web.php')); - } + fn () => $this->loadRoutesFrom(realpath(__DIR__.'/../../routes/web.php')) ); } } diff --git a/src/Result.php b/src/Result.php index 17856cd..4350777 100644 --- a/src/Result.php +++ b/src/Result.php @@ -13,18 +13,16 @@ /** * Class Result * - * @package Spinen\ClickUp - * * @property array $last_action - * @property boolean $completed + * @property bool $completed * @property Carbon $date_created * @property Collection $owners * @property Collection $subcategory_ids * @property Collection $task_ids * @property float $percent_completed * @property Goal $goal - * @property integer $creator - * @property integer $goal_pretty_id + * @property int $creator + * @property int $goal_pretty_id * @property string $goal_id * @property string $id * @property string $name @@ -39,11 +37,11 @@ class Result extends Model * @var array */ protected $casts = [ - 'completed' => 'boolean', - 'creator' => 'integer', - 'date_created' => 'datetime:Uv', - 'goal_pretty_id' => 'integer', - 'id' => 'string', + 'completed' => 'boolean', + 'creator' => 'integer', + 'date_created' => 'datetime:Uv', + 'goal_pretty_id' => 'integer', + 'id' => 'string', 'percent_completed' => 'float', ]; @@ -53,33 +51,27 @@ class Result extends Model * Several of the endpoints are nested behind another model for relationship, but then to * interact with the specific model, then are not nested. This property will know when to * keep the specific model nested. - * - * @var bool */ - protected $nested = true; + protected bool $nested = true; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/key_result'; + protected string $path = '/key_result'; /** * Accessor for Owners. * - * @param array $owners - * - * @return Collection * @throws NoClientException */ - public function getOwnersAttribute(array $owners): Collection + public function getOwnersAttribute(?array $owners): Collection { return $this->givenMany(Member::class, $owners); } /** - * @return ChildOf + * Child of Goal + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Share.php b/src/Share.php index 746dc99..7d3e212 100644 --- a/src/Share.php +++ b/src/Share.php @@ -12,8 +12,6 @@ /** * Class Share * - * @package Spinen\ClickUp - * * @property Collection $folders * @property Collection $lists * @property Collection $tasks @@ -23,20 +21,15 @@ class Share extends Model { /** * Path to API endpoint. - * - * @var string */ - protected $path = '/share'; + protected string $path = '/share'; /** * Accessor for Folders. * - * @param array $folders - * - * @return Collection * @throws NoClientException */ - public function getFoldersAttribute(array $folders): Collection + public function getFoldersAttribute(?array $folders): Collection { return $this->givenMany(Folder::class, $folders); } @@ -44,12 +37,9 @@ public function getFoldersAttribute(array $folders): Collection /** * Accessor for Lists. * - * @param array $lists - * - * @return Collection * @throws NoClientException */ - public function getListsAttribute(array $lists): Collection + public function getListsAttribute(?array $lists): Collection { return $this->givenMany(TaskList::class, $lists); } @@ -57,18 +47,16 @@ public function getListsAttribute(array $lists): Collection /** * Accessor for Tasks. * - * @param array $tasks - * - * @return Collection * @throws NoClientException */ - public function getTasksAttribute(array $tasks): Collection + public function getTasksAttribute(?array $tasks): Collection { return $this->givenMany(Task::class, $tasks); } /** - * @return ChildOf + * Child of Team + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Space.php b/src/Space.php index 09c5376..1ac86bb 100644 --- a/src/Space.php +++ b/src/Space.php @@ -13,19 +13,18 @@ /** * Class Space * - * @package Spinen\ClickUp - * * @property array $features - * @property boolean $archived - * @property boolean $multiple_assignees - * @property boolean $private + * @property bool $archived + * @property bool $multiple_assignees + * @property bool $private * @property Collection $folders + * @property Collection $lists * @property Collection $members * @property Collection $statuses * @property Collection $tags * @property Collection $taskLists * @property Collection $views - * @property integer $id + * @property int $id * @property string $name * @property Team $team */ @@ -37,28 +36,23 @@ class Space extends Model * @var array */ protected $casts = [ - 'archived' => 'boolean', - 'id' => 'integer', + 'archived' => 'boolean', + 'id' => 'integer', 'multiple_assignees' => 'boolean', - 'private' => 'boolean', + 'private' => 'boolean', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/space'; + protected string $path = '/space'; /** * Accessor for Members. * - * @param array $members - * - * @return Collection * @throws NoClientException */ - public function getMembersAttribute(array $members): Collection + public function getMembersAttribute(?array $members): Collection { return $this->givenMany(Member::class, $members, true); } @@ -66,19 +60,16 @@ public function getMembersAttribute(array $members): Collection /** * Accessor for Statuses. * - * @param array $statuses - * - * @return Collection * @throws NoClientException */ - public function getStatusesAttribute(array $statuses): Collection + public function getStatusesAttribute(?array $statuses): Collection { return $this->givenMany(Status::class, $statuses); } /** - * @return HasMany - + * Has many Folders + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -89,8 +80,8 @@ public function folders(): HasMany } /** - * @return HasMany - + * Has many TaskLists + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -101,8 +92,8 @@ public function lists(): HasMany } /** - * @return HasMany - + * Has many Tags + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -113,7 +104,8 @@ public function tags(): HasMany } /** - * @return ChildOf + * Child of Team + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -124,8 +116,8 @@ public function team(): ChildOf } /** - * @return HasMany - + * Has many Views + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Status.php b/src/Status.php index cf2bfb6..9c5da75 100644 --- a/src/Status.php +++ b/src/Status.php @@ -7,8 +7,6 @@ /** * Class Status * - * @package Spinen\ClickUp - * * @property string $status * @property string $color * @property float $orderindex @@ -27,8 +25,6 @@ class Status extends Model /** * Is the model readonly? - * - * @var bool */ - protected $readonlyModel = true; + protected bool $readonlyModel = true; } diff --git a/src/Support/Builder.php b/src/Support/Builder.php index 423ed87..b530099 100644 --- a/src/Support/Builder.php +++ b/src/Support/Builder.php @@ -19,8 +19,6 @@ /** * Class Builder * - * @package Spinen\ClickUp\Support - * * @property Collection $spaces * @property Collection $tasks * @property Collection $teams @@ -38,24 +36,18 @@ class Builder /** * Class to cast the response - * - * @var string */ - protected $class; + protected string $class; /** * Model instance - * - * @var Model */ - protected $model; + protected Model $model; /** * Parent model instance - * - * @var Model */ - protected $parentModel; + protected ?Model $parentModel = null; /** * Map of potential parents with class name @@ -63,63 +55,54 @@ class Builder * @var array */ protected $rootModels = [ - 'spaces' => Space::class, - 'tasks' => Task::class, - 'teams' => Team::class, + 'spaces' => Space::class, + 'tasks' => Task::class, + 'teams' => Team::class, 'workspaces' => Team::class, ]; /** * Properties to filter the response - * - * @var array */ - protected $wheres = []; + protected array $wheres = []; /** * Magic method to make builders for root models * - * @param string $name - * @param $arguments - * - * @return mixed * @throws BadMethodCallException * @throws ModelNotFoundException * @throws NoClientException */ - public function __call($name, $arguments) + public function __call(string $name, array $arguments) { - if (!$this->parentModel && array_key_exists($name, $this->rootModels)) { + if (! isset($this->parentModel) && array_key_exists($name, $this->rootModels)) { return $this->newInstanceForModel($this->rootModels[$name]); } - throw new BadMethodCallException(sprintf("Call to undefined method [%s]", $name)); + throw new BadMethodCallException(sprintf('Call to undefined method [%s]', $name)); } /** * Magic method to make builders appears as properties * - * @param string $name - * - * @return Collection|Model|null * @throws GuzzleException * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException * @throws TokenException */ - public function __get($name) + public function __get(string $name): Collection|Model|null { if ($name === 'user') { return $this->newInstanceForModel(User::class) - ->get() - ->first(); + ->get() + ->first(); } // Only return builders as properties, when not a child - if (!$this->parentModel && array_key_exists($name, $this->rootModels)) { + if (! $this->parentModel && array_key_exists($name, $this->rootModels)) { return $this->{$name}() - ->get(); + ->get(); } return null; @@ -128,163 +111,139 @@ public function __get($name) /** * Create instance of class and save via API * - * @param array $attributes - * - * @return Model * @throws InvalidRelationshipException */ public function create(array $attributes): Model { return tap( $this->make($attributes), - function (Model $model) { - $model->save(); - } + fn (Model $model): bool => $model->save() ); } /** * Get Collection of class instances that match query * - * @param array|string $properties to pull - * - * @return Collection|Model * @throws GuzzleException * @throws InvalidRelationshipException * @throws NoClientException * @throws TokenException */ - public function get($properties = ['*']) + public function get(array|string $properties = ['*']): Collection|Model { $properties = Arr::wrap($properties); // Call API to get the response $response = $this->getClient() - ->request($this->getPath()); + ->request($this->getPath()); // Peel off the key if exist $response = $this->peelWrapperPropertyIfNeeded(Arr::wrap($response)); // Convert to a collection of filtered objects casted to the class return (new Collection((array_values($response) === $response) ? $response : [$response]))->map( - function ($items) use ($properties) { - // Cast to class with only the requested, properties - return $this->getModel() - ->newFromBuilder( - $properties === ['*'] - ? (array)$items - : collect($items) - ->only($properties) - ->toArray() - ) - ->setClient($this->getClient()); - } + // Cast to class with only the requested, properties + fn ($items) => $this->getModel() + ->newFromBuilder( + $properties === ['*'] + ? (array) $items + : collect($items) + ->only($properties) + ->toArray() + ) + ->setClient($this->getClient()) ); } /** * Get the model instance being queried. * - * @return Model * @throws InvalidRelationshipException */ public function getModel(): Model { - if (!$this->class) { + if (! isset($this->class)) { throw new InvalidRelationshipException(); } - if (!$this->model) { + if (! isset($this->model)) { $this->model = (new $this->class([], $this->parentModel))->setClient($this->client); } return $this->model; } - /** * Get the path for the resource with the where filters * - * @param string|null $extra - * - * @return string|null * @throws InvalidRelationshipException */ - public function getPath($extra = null): ?string + public function getPath(?string $extra = null): ?string { return $this->getModel() - ->getPath($extra, $this->wheres); + ->getPath($extra, $this->wheres); } /** * Find specific instance of class * - * @param integer|string $id - * @param array|string $properties to pull - * - * @return Model * @throws GuzzleException * @throws InvalidRelationshipException * @throws NoClientException * @throws TokenException */ - public function find($id, $properties = ['*']): Model + public function find(int|string $id, array|string $properties = ['*']): Model { return $this->where($this->getModel()->getKeyName(), $id) - ->get($properties) - ->first(); + ->get($properties) + ->first(); } /** * New up a class instance, but not saved * - * @param array|null $attributes - * - * @return Model * @throws InvalidRelationshipException */ - public function make(array $attributes = []): Model + public function make(?array $attributes = []): Model { // TODO: Make sure that the model supports "creating" return $this->getModel() - ->newInstance($attributes); + ->newInstance($attributes); } /** * Create new Builder instance * - * @return $this * @throws ModelNotFoundException * @throws NoClientException */ public function newInstance(): self { - return (new static())->setClass($this->class) - ->setClient($this->getClient()) - ->setParent($this->parentModel); + return isset($this->class) + ? (new static()) + ->setClass($this->class) + ->setClient($this->getClient()) + ->setParent($this->parentModel) + : (new static()) + ->setClient($this->getClient()) + ->setParent($this->parentModel); } /** * Create new Builder instance for a specific model * - * @param string $model - * - * @return $this * @throws ModelNotFoundException * @throws NoClientException */ - public function newInstanceForModel($model): self + public function newInstanceForModel(string $model): self { return $this->newInstance() - ->setClass($model); + ->setClass($model); } /** * Peel of the wrapping property if it exist. * - * @param array $properties - * - * @return array * @throws InvalidRelationshipException */ protected function peelWrapperPropertyIfNeeded(array $properties): array @@ -292,21 +251,21 @@ protected function peelWrapperPropertyIfNeeded(array $properties): array // Check for single response if (array_key_exists( $this->getModel() - ->getResponseKey(), + ->getResponseKey(), $properties )) { return $properties[$this->getModel() - ->getResponseKey()]; + ->getResponseKey()]; } // Check for collection of responses if (array_key_exists( $this->getModel() - ->getResponseCollectionKey(), + ->getResponseCollectionKey(), $properties )) { return $properties[$this->getModel() - ->getResponseCollectionKey()]; + ->getResponseCollectionKey()]; } return $properties; @@ -315,28 +274,21 @@ protected function peelWrapperPropertyIfNeeded(array $properties): array /** * Set the class to cast the response * - * @param string $class - * - * @return $this * @throws ModelNotFoundException */ - public function setClass($class): self + public function setClass(string $class): self { - $this->class = $class; - - if (!is_null($class) && !class_exists($this->class)) { - throw new ModelNotFoundException(sprintf("The model [%s] not found.", $this->class)); + if (! class_exists($class)) { + throw new ModelNotFoundException(sprintf('The model [%s] not found.', $class)); } + $this->class = $class; + return $this; } /** * Set the parent model - * - * @param Model $parent - * - * @return $this */ public function setParent(?Model $parent): self { @@ -348,13 +300,9 @@ public function setParent(?Model $parent): self /** * Add property to filter the collection * - * @param string $property - * @param mixed $value - * - * @return $this * @throws InvalidRelationshipException */ - public function where($property, $value = true): self + public function where(string $property, $value = true): self { $value = is_a($value, LaravelCollection::class) ? $value->toArray() : $value; @@ -373,12 +321,9 @@ public function where($property, $value = true): self /** * Shortcut to where property id * - * @param integer|string $id - * - * @return $this * @throws InvalidRelationshipException */ - public function whereId($id): self + public function whereId(int|string|null $id): self { return $this->where($this->getModel()->getKeyName(), $id); } @@ -386,12 +331,9 @@ public function whereId($id): self /** * Shortcut to where property is false * - * @param string $property - * - * @return $this * @throws InvalidRelationshipException */ - public function whereNot($property): self + public function whereNot(string $property): self { return $this->where($property, false); } diff --git a/src/Support/Collection.php b/src/Support/Collection.php index 26f7282..f22dbb8 100644 --- a/src/Support/Collection.php +++ b/src/Support/Collection.php @@ -6,5 +6,4 @@ class Collection extends BaseCollection { - } diff --git a/src/Support/Model.php b/src/Support/Model.php index 21aa252..6de3670 100644 --- a/src/Support/Model.php +++ b/src/Support/Model.php @@ -29,8 +29,6 @@ /** * Class Model - * - * @package Spinen\ClickUp\Support */ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializable { @@ -41,24 +39,18 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab /** * Indicates if the model exists. - * - * @var bool */ - public $exists = false; + public bool $exists = false; /** * Indicates if the IDs are auto-incrementing. - * - * @var bool */ - public $incrementing = false; + public bool $incrementing = false; /** * The "type" of the primary key ID. - * - * @var string */ - protected $keyType = 'int'; + protected string $keyType = 'int'; /** * Is resource nested behind parentModel @@ -66,66 +58,48 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab * Several of the endpoints are nested behind another model for relationship, but then to * interact with the specific model, then are not nested. This property will know when to * keep the specific model nested. - * - * @var bool */ - protected $nested = false; + protected bool $nested = false; /** * Optional parentModel instance - * - * @var Model $parentModel */ - public $parentModel; + public ?Model $parentModel; /** * Path to API endpoint. - * - * @var string */ - protected $path = null; + protected string $path; /** * The primary key for the model. - * - * @var string */ - protected $primaryKey = 'id'; + protected string $primaryKey = 'id'; /** * Is the model readonly? - * - * @var bool */ - protected $readonlyModel = false; + protected bool $readonlyModel = false; /** * The loaded relationships for the model. - * - * @var array */ - protected $relations = []; + protected array $relations = []; /** * Some of the responses have the collections under a property - * - * @var string|null */ - protected $responseCollectionKey = null; + protected ?string $responseCollectionKey = null; /** * Some of the responses have the data under a property - * - * @var string|null */ - protected $responseKey = null; + protected ?string $responseKey = null; /** * Are timestamps in milliseconds? - * - * @var boolean */ - protected $timestampsInMilliseconds = true; + protected bool $timestampsInMilliseconds = true; /** * The name of the "created at" column. @@ -143,11 +117,8 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab /** * Model constructor. - * - * @param array|null $attributes - * @param Model|null $parentModel */ - public function __construct(array $attributes = [], Model $parentModel = null) + public function __construct(?array $attributes = [], Model $parentModel = null) { // All dates from API comes as epoch with milliseconds $this->dateFormat = 'Uv'; @@ -162,24 +133,16 @@ public function __construct(array $attributes = [], Model $parentModel = null) /** * Dynamically retrieve attributes on the model. - * - * @param string $key - * - * @return mixed */ - public function __get($key) + public function __get(string $key) { return $this->getAttribute($key); } /** * Determine if an attribute or relation exists on the model. - * - * @param string $key - * - * @return bool */ - public function __isset($key) + public function __isset(string $key): bool { return $this->offsetExists($key); } @@ -187,10 +150,9 @@ public function __isset($key) /** * Dynamically set attributes on the model. * - * @param string $key - * @param mixed $value - * + * @param string $key * @return void + * * @throws ModelReadonlyException */ public function __set($key, $value) @@ -215,8 +177,7 @@ public function __toString() /** * Unset an attribute on the model. * - * @param string $key - * + * @param string $key * @return void */ public function __unset($key) @@ -227,7 +188,6 @@ public function __unset($key) /** * Return a timestamp as DateTime object. * - * @param mixed $value * @return Carbon */ protected function asDateTime($value) @@ -242,22 +202,19 @@ protected function asDateTime($value) /** * Assume foreign key * - * @param string $related - * - * @return string + * @param string $related */ protected function assumeForeignKey($related): string { - return Str::snake((new $related())->getResponseKey()) . '_id'; + return Str::snake((new $related())->getResponseKey()).'_id'; } /** * Relationship that makes the model belongs to another model * - * @param string $related - * @param string|null $foreignKey + * @param string $related + * @param string|null $foreignKey * - * @return BelongsTo * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -275,10 +232,9 @@ public function belongsTo($related, $foreignKey = null): BelongsTo /** * Relationship that makes the model child to another model * - * @param string $related - * @param string|null $foreignKey + * @param string $related + * @param string|null $foreignKey * - * @return ChildOf * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -297,7 +253,6 @@ public function childOf($related, $foreignKey = null): ChildOf /** * Delete the model from ClickUp * - * @return boolean * @throws NoClientException * @throws TokenException */ @@ -322,14 +277,10 @@ public function delete(): bool /** * Fill the model with the supplied properties - * - * @param array $attributes - * - * @return $this */ - public function fill(array $attributes = []): self + public function fill(?array $attributes = []): self { - foreach ($attributes as $attribute => $value) { + foreach ((array) $attributes as $attribute => $value) { $this->setAttribute($attribute, $value); } @@ -338,8 +289,6 @@ public function fill(array $attributes = []): self /** * Get the value indicating whether the IDs are incrementing. - * - * @return bool */ public function getIncrementing(): bool { @@ -348,8 +297,6 @@ public function getIncrementing(): bool /** * Get the value of the model's primary key. - * - * @return mixed */ public function getKey() { @@ -358,8 +305,6 @@ public function getKey() /** * Get the primary key for the model. - * - * @return string */ public function getKeyName(): string { @@ -368,8 +313,6 @@ public function getKeyName(): string /** * Get the auto-incrementing key type. - * - * @return string */ public function getKeyType(): string { @@ -381,9 +324,8 @@ public function getKeyType(): string * * Put anything on the end of the URI that is passed in * - * @param string|null $extra - * @param array|null $query - * + * @param string|null $extra + * @param array|null $query * @return string */ public function getPath($extra = null, array $query = []): ?string @@ -393,21 +335,21 @@ public function getPath($extra = null, array $query = []): ?string // If have an id, then put it on the end if ($this->getKey()) { - $path .= '/' . $this->getKey(); + $path .= '/'.$this->getKey(); } // Stick any extra things on the end - if (!is_null($extra)) { - $path .= '/' . ltrim($extra, '/'); + if (! is_null($extra)) { + $path .= '/'.ltrim($extra, '/'); } // Convert query to querystring format and put on the end - if (!empty($query)) { - $path .= '?' . http_build_query($query); + if (! empty($query)) { + $path .= '?'.http_build_query($query); } // If there is a parentModel & not have an id (unless for nested), then prepend parentModel - if (!is_null($this->parentModel) && (!$this->getKey() || $this->isNested())) { + if (! is_null($this->parentModel) && (! $this->getKey() || $this->isNested())) { return $this->parentModel->getPath($path); } @@ -417,9 +359,7 @@ public function getPath($extra = null, array $query = []): ?string /** * Get a relationship value from a method. * - * @param string $method - * - * @return mixed + * @param string $method * * @throws LogicException */ @@ -427,7 +367,7 @@ public function getRelationshipFromMethod($method) { $relation = $this->{$method}(); - if (!$relation instanceof Relation) { + if (! $relation instanceof Relation) { $exception_message = is_null($relation) ? '%s::%s must return a relationship instance, but "null" was returned. Was the "return" keyword used?' : '%s::%s must return a relationship instance.'; @@ -449,8 +389,6 @@ function ($results) use ($method) { * Name of the wrapping key when response is a collection * * If none provided, assume plural version responseKey - * - * @return string|null */ public function getResponseCollectionKey(): ?string { @@ -461,8 +399,6 @@ public function getResponseCollectionKey(): ?string * Name of the wrapping key of response * * If none provided, assume camelCase of class name - * - * @return string|null */ public function getResponseKey(): ?string { @@ -472,11 +408,10 @@ public function getResponseKey(): ?string /** * Many of the results include collection of related data, so cast it * - * @param string $related - * @param array $given - * @param bool $reset Some of the values are nested under a property, so peel it off + * @param string $related + * @param array $given + * @param bool $reset Some of the values are nested under a property, so peel it off * - * @return Collection * @throws NoClientException */ public function givenMany($related, $given, $reset = false): Collection @@ -494,11 +429,10 @@ function ($attributes) use ($model, $reset) { /** * Many of the results include related data, so cast it to object * - * @param string $related - * @param array $attributes - * @param bool $reset Some of the values are nested under a property, so peel it off + * @param string $related + * @param array $attributes + * @param bool $reset Some of the values are nested under a property, so peel it off * - * @return Model * @throws NoClientException */ public function givenOne($related, $attributes, $reset = false): Model @@ -510,9 +444,8 @@ public function givenOne($related, $attributes, $reset = false): Model /** * Relationship that makes the model have a collection of another model * - * @param string $related + * @param string $related * - * @return HasMany * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -528,8 +461,6 @@ public function hasMany($related): HasMany /** * Is endpoint nested behind another endpoint - * - * @return bool */ public function isNested(): bool { @@ -538,8 +469,6 @@ public function isNested(): bool /** * Convert the object into something JSON serializable. - * - * @return array */ public function jsonSerialize(): array { @@ -549,15 +478,14 @@ public function jsonSerialize(): array /** * Create a new model instance that is existing. * - * @param array $attributes - * + * @param array $attributes * @return static */ public function newFromBuilder($attributes = []): self { $model = $this->newInstance([], true); - $model->setRawAttributes((array)$attributes, true); + $model->setRawAttributes((array) $attributes, true); return $model; } @@ -568,9 +496,7 @@ public function newFromBuilder($attributes = []): self * Provides a convenient way for us to generate fresh model instances of this current model. * It is particularly useful during the hydration of new objects via the builder. * - * @param array $attributes - * @param bool $exists - * + * @param bool $exists * @return static */ public function newInstance(array $attributes = [], $exists = false): self @@ -584,24 +510,16 @@ public function newInstance(array $attributes = [], $exists = false): self /** * Determine if the given attribute exists. - * - * @param mixed $offset - * - * @return bool */ - public function offsetExists($offset) + public function offsetExists($offset): bool { - return !is_null($this->getAttribute($offset)); + return ! is_null($this->getAttribute($offset)); } /** * Get the value for a given offset. - * - * @param mixed $offset - * - * @return mixed */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->getAttribute($offset); } @@ -609,10 +527,7 @@ public function offsetGet($offset) /** * Set the value for a given offset. * - * @param mixed $offset - * @param mixed $value * - * @return void * @throws ModelReadonlyException */ public function offsetSet($offset, $value): void @@ -626,10 +541,6 @@ public function offsetSet($offset, $value): void /** * Unset the value for a given offset. - * - * @param mixed $offset - * - * @return void */ public function offsetUnset($offset): void { @@ -639,19 +550,28 @@ public function offsetUnset($offset): void /** * Determine if the given relation is loaded. * - * @param string $key - * - * @return bool + * @param string $key */ public function relationLoaded($key): bool { return array_key_exists($key, $this->relations); } + /** + * Laravel allows the resolver to be set at runtime, so we just return null + * + * @param string $class + * @param string $key + * @return null + */ + public function relationResolver($class, $key) + { + return null; + } + /** * Save the model in ClickUp * - * @return bool * @throws NoClientException * @throws TokenException */ @@ -663,7 +583,7 @@ public function save(): bool } try { - if (!$this->isDirty()) { + if (! $this->isDirty()) { return true; } @@ -690,7 +610,6 @@ public function save(): bool $this->setRawAttributes($response, true); return true; - } catch (GuzzleException $e) { // TODO: Do something with the error @@ -701,26 +620,23 @@ public function save(): bool /** * Save the model in ClickUp, but raise error if fail * - * @return bool * @throws NoClientException * @throws TokenException * @throws UnableToSaveException */ public function saveOrFail(): bool { - if (!$this->save()) { + if (! $this->save()) { throw new UnableToSaveException(); } return true; } - /** * Set the readonly * - * @param bool $readonly - * + * @param bool $readonly * @return $this */ public function setReadonly($readonly = true): self @@ -733,9 +649,7 @@ public function setReadonly($readonly = true): self /** * Set the given relationship on the model. * - * @param string $relation - * @param mixed $value - * + * @param string $relation * @return $this */ public function setRelation($relation, $value): self @@ -747,8 +661,6 @@ public function setRelation($relation, $value): self /** * Convert the model instance to an array. - * - * @return array */ public function toArray(): array { @@ -758,9 +670,7 @@ public function toArray(): array /** * Convert the model instance to JSON. * - * @param int $options - * - * @return string + * @param int $options * * @throws JsonEncodingException */ diff --git a/src/Support/Relations/BelongsTo.php b/src/Support/Relations/BelongsTo.php index ff6cf13..406f156 100644 --- a/src/Support/Relations/BelongsTo.php +++ b/src/Support/Relations/BelongsTo.php @@ -11,49 +11,28 @@ /** * Class BelongsTo - * - * @package Spinen\ClickUp\Support\Relations */ class BelongsTo extends Relation { - /** - * The child model instance of the relation. - */ - protected $child; - - /** - * The foreign key of the parentModel model. - * - * @var string - */ - protected $foreignKey; - /** * Create a new belongs to relationship instance. * - * @param Builder $builder - * @param Model $child - * @param string $foreignKey - * * @return void + * * @throws InvalidRelationshipException */ - public function __construct(Builder $builder, Model $child, $foreignKey) + public function __construct(protected Builder $builder, protected Model $child, protected $foreignKey) { - $this->foreignKey = $foreignKey; - - // In the underlying base relationship class, this variable is referred to as - // the "parentModel" since most relationships are not inversed. But, since this - // one is we will create a "child" variable for much better readability. - $this->child = $child; + // In the underlying base relationship class, the "child" variable is + // referred to as the "parentModel" since most relationships are not + // inversed. But, since this one is we will create a "child" variable + // for much better readability. parent::__construct($builder->whereId($this->getForeignKey()), $this->getChild()); } /** * Get the child Model - * - * @return Model */ public function getChild(): Model { @@ -62,18 +41,14 @@ public function getChild(): Model /** * Get the foreign key's name - * - * @return integer|string */ - public function getForeignKey() + public function getForeignKey(): int|string|null { return $this->getChild()->{$this->getForeignKeyName()}; } /** * Get the name of the foreign key's name - * - * @return string */ public function getForeignKeyName(): string { @@ -83,7 +58,6 @@ public function getForeignKeyName(): string /** * Get the results of the relationship. * - * @return Model|null * @throws GuzzleException * @throws InvalidRelationshipException * @throws NoClientException @@ -91,7 +65,7 @@ public function getForeignKeyName(): string */ public function getResults(): ?Model { - if (!$this->getForeignKey()) { + if (! $this->getForeignKey()) { return null; } diff --git a/src/Support/Relations/ChildOf.php b/src/Support/Relations/ChildOf.php index cbef933..0d3c5c9 100644 --- a/src/Support/Relations/ChildOf.php +++ b/src/Support/Relations/ChildOf.php @@ -6,15 +6,11 @@ /** * Class ChildOf - * - * @package Spinen\ClickUp\Support\Relations */ class ChildOf extends BelongsTo { /** * Get the results of the relationship. - * - * @return Model */ public function getResults(): Model { diff --git a/src/Support/Relations/HasMany.php b/src/Support/Relations/HasMany.php index c0f6879..093df0a 100644 --- a/src/Support/Relations/HasMany.php +++ b/src/Support/Relations/HasMany.php @@ -10,15 +10,12 @@ /** * Class HasMany - * - * @package Spinen\ClickUp\Support\Relations */ class HasMany extends Relation { /** * Get the results of the relationship. * - * @return Collection * @throws GuzzleException * @throws InvalidRelationshipException * @throws NoClientException diff --git a/src/Support/Relations/Relation.php b/src/Support/Relations/Relation.php index 0867241..a771754 100644 --- a/src/Support/Relations/Relation.php +++ b/src/Support/Relations/Relation.php @@ -10,8 +10,6 @@ /** * Class Relation - * - * @package Spinen\ClickUp\Support\Relations */ abstract class Relation { @@ -19,52 +17,28 @@ abstract class Relation __call as macroCall; } - /** - * The Eloquent builder builder instance. - * - * @var Builder - */ - protected $builder; - - /** - * The parent model instance. - * - * @var Model - */ - protected $parent; - /** * The related model instance. - * - * @var Model */ - protected $related; + protected Model $related; /** * Create a new relation instance. * - * @param Builder $builder - * @param Model $parent * * @return void + * * @throws InvalidRelationshipException */ - public function __construct(Builder $builder, Model $parent) + public function __construct(protected Builder $builder, protected Model $parent) { - $this->builder = $builder; - $this->parent = $parent; $this->related = $builder->getModel(); } /** * Handle dynamic method calls to the relationship. - * - * @param string $method - * @param array $parameters - * - * @return mixed */ - public function __call($method, $parameters) + public function __call(string $method, array $parameters) { if (static::hasMacro($method)) { return $this->macroCall($method, $parameters); @@ -81,8 +55,6 @@ public function __call($method, $parameters) /** * Get the Builder instance - * - * @return Builder */ public function getBuilder(): Builder { @@ -91,8 +63,6 @@ public function getBuilder(): Builder /** * Get the parent Model instance - * - * @return Model */ public function getParent(): Model { @@ -101,8 +71,6 @@ public function getParent(): Model /** * Get the related Model instance - * - * @return Model */ public function getRelated(): Model { @@ -111,8 +79,6 @@ public function getRelated(): Model /** * Get the results of the relationship. - * - * @return mixed */ abstract public function getResults(); } diff --git a/src/Tag.php b/src/Tag.php index 2e0ac1c..0863edb 100644 --- a/src/Tag.php +++ b/src/Tag.php @@ -11,11 +11,10 @@ /** * Class Tag * - * @package Spinen\ClickUp - * + * @property Space $space * @property string $name - * @property string $tag_fg * @property string $tag_bg + * @property string $tag_fg */ class Tag extends Model { @@ -25,20 +24,17 @@ class Tag extends Model * Several of the endpoints are nested behind another model for relationship, but then to * interact with the specific model, then are not nested. This property will know when to * keep the specific model nested. - * - * @var bool */ - protected $nested = true; + protected bool $nested = true; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/tag'; + protected string $path = '/tag'; /** - * @return ChildOf + * Child of Space + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Task.php b/src/Task.php index cc93641..a34fbe5 100644 --- a/src/Task.php +++ b/src/Task.php @@ -2,10 +2,10 @@ namespace Spinen\ClickUp; +use Carbon\Carbon; use Spinen\ClickUp\Exceptions\InvalidRelationshipException; use Spinen\ClickUp\Exceptions\ModelNotFoundException; use Spinen\ClickUp\Exceptions\NoClientException; -use Carbon\Carbon; use Spinen\ClickUp\Support\Collection; use Spinen\ClickUp\Support\Model; use Spinen\ClickUp\Support\Relations\BelongsTo; @@ -15,9 +15,7 @@ /** * Class Task * - * @package Spinen\ClickUp - * - * @property boolean $archived + * @property bool $archived * @property array $attachments * @property array $dependencies * @property Carbon $date_closed @@ -34,9 +32,9 @@ * @property Collection $times * @property float $orderindex * @property Folder $folder - * @property integer $team_id - * @property integer $time_estimate - * @property integer $time_spent + * @property int $team_id + * @property int $time_estimate + * @property int $time_spent * @property Member $creator * @property Priority $priority * @property Project $project @@ -46,8 +44,8 @@ * @property string $name * @property string $url * @property Task $parent - * @property TaskList $list - * @property Team $team + * @property TaskList|null $list + * @property Team|null $team * @property View $view */ class Task extends Model @@ -58,29 +56,27 @@ class Task extends Model * @var array */ protected $casts = [ - 'archived' => 'boolean', - 'date_closed' => 'datetime:Uv', - 'date_created' => 'datetime:Uv', - 'date_updated' => 'datetime:Uv', - 'due_date' => 'datetime:Uv', - 'id' => 'string', - 'orderindex' => 'float', - 'start_date' => 'datetime:Uv', - 'team_id' => 'integer', + 'archived' => 'boolean', + 'date_closed' => 'datetime:Uv', + 'date_created' => 'datetime:Uv', + 'date_updated' => 'datetime:Uv', + 'due_date' => 'datetime:Uv', + 'id' => 'string', + 'orderindex' => 'float', + 'start_date' => 'datetime:Uv', + 'team_id' => 'integer', 'time_estimate' => 'integer', - 'time_spent' => 'integer', + 'time_spent' => 'integer', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/task'; + protected string $path = '/task'; /** - * @return HasMany - + * Has many Comments + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -93,12 +89,9 @@ public function comments(): HasMany /** * Accessor for Assignees. * - * @param array $assignees - * - * @return Collection * @throws NoClientException */ - public function getAssigneesAttribute(array $assignees): Collection + public function getAssigneesAttribute(?array $assignees): Collection { return $this->givenMany(Member::class, $assignees); } @@ -106,12 +99,9 @@ public function getAssigneesAttribute(array $assignees): Collection /** * Accessor for Checklists. * - * @param array $checklists - * - * @return Collection * @throws NoClientException */ - public function getChecklistsAttribute(array $checklists): Collection + public function getChecklistsAttribute(?array $checklists): Collection { return $this->givenMany(Checklist::class, $checklists); } @@ -119,12 +109,9 @@ public function getChecklistsAttribute(array $checklists): Collection /** * Accessor for Creator. * - * @param array $creator - * - * @return Member * @throws NoClientException */ - public function getCreatorAttribute($creator): Member + public function getCreatorAttribute(?array $creator): Member { return $this->givenOne(Member::class, $creator); } @@ -132,12 +119,9 @@ public function getCreatorAttribute($creator): Member /** * Accessor for CustomFields. * - * @param array $custom_fields - * - * @return Collection * @throws NoClientException */ - public function getCustomFieldsAttribute(array $custom_fields): Collection + public function getCustomFieldsAttribute(?array $custom_fields): Collection { return $this->givenMany(Field::class, $custom_fields); } @@ -145,12 +129,9 @@ public function getCustomFieldsAttribute(array $custom_fields): Collection /** * Accessor for Folder. * - * @param array $folder - * - * @return Folder * @throws NoClientException */ - public function getFolderAttribute($folder): Folder + public function getFolderAttribute(?array $folder): Folder { return $this->givenOne(Folder::class, $folder); } @@ -158,12 +139,10 @@ public function getFolderAttribute($folder): Folder /** * Accessor for Parent. * - * @param string $parent - * - * @return Task + * @throws NoClientException */ // TODO: Figure out how to make this relationship work - /*public function getParentAttribute($parent): Task + /*public function getParentAttribute(?array $parent): Task { return $this->parentModel; }*/ @@ -171,12 +150,9 @@ public function getFolderAttribute($folder): Folder /** * Accessor for Priority. * - * @param array $priority - * - * @return Priority * @throws NoClientException */ - public function getPriorityAttribute($priority): Priority + public function getPriorityAttribute(?array $priority): Priority { return $this->givenOne(Priority::class, $priority); } @@ -184,12 +160,9 @@ public function getPriorityAttribute($priority): Priority /** * Accessor for Project. * - * @param array $project - * - * @return Project * @throws NoClientException */ - public function getProjectAttribute($project): Project + public function getProjectAttribute(?array $project): Project { // TODO: This is not documented. I think it is a hold over from v1? return $this->givenOne(Project::class, $project); @@ -198,12 +171,9 @@ public function getProjectAttribute($project): Project /** * Accessor for Space. * - * @param array $space - * - * @return Space * @throws NoClientException */ - public function getSpaceAttribute($space): Space + public function getSpaceAttribute(?array $space): Space { // TODO: Look into making this a relationship return $this->givenOne(Space::class, $space); @@ -212,12 +182,9 @@ public function getSpaceAttribute($space): Space /** * Accessor for Status. * - * @param array $status - * - * @return Status * @throws NoClientException */ - public function getStatusAttribute($status): Status + public function getStatusAttribute(?array $status): Status { return $this->givenOne(Status::class, $status); } @@ -225,18 +192,16 @@ public function getStatusAttribute($status): Status /** * Accessor for Tags. * - * @param array $tags - * - * @return Collection * @throws NoClientException */ - public function getTagsAttribute(array $tags): Collection + public function getTagsAttribute(?array $tags): Collection { return $this->givenMany(Tag::class, $tags); } /** - * @return ChildOf + * Optional Child of TaskList + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -247,8 +212,8 @@ public function list(): ?ChildOf } /** - * @return HasMany - + * Has many Members + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -259,7 +224,10 @@ public function members(): HasMany } /** + * Optional Child of Team + * * @return ChildOf + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -270,8 +238,8 @@ public function team(): ?ChildOf } /** - * @return HasMany - + * Has many Times + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -282,7 +250,8 @@ public function times(): HasMany } /** - * @return BelongsTo + * Belongs to View + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/TaskList.php b/src/TaskList.php index 68acbce..11c50e8 100644 --- a/src/TaskList.php +++ b/src/TaskList.php @@ -2,10 +2,10 @@ namespace Spinen\ClickUp; +use Carbon\Carbon; use Spinen\ClickUp\Exceptions\InvalidRelationshipException; use Spinen\ClickUp\Exceptions\ModelNotFoundException; use Spinen\ClickUp\Exceptions\NoClientException; -use Carbon\Carbon; use Spinen\ClickUp\Support\Collection; use Spinen\ClickUp\Support\Model; use Spinen\ClickUp\Support\Relations\ChildOf; @@ -14,20 +14,26 @@ /** * Class TaskList * - * @package Spinen\ClickUp - * - * @property boolean $archived - * @property boolean $due_date_time - * @property boolean $override_statuses - * @property boolean $start_date_time + * @property bool $archived + * @property bool $due_date_time + * @property bool $override_statuses + * @property bool $start_date_time * @property Carbon $due_date * @property Carbon $start_date + * @property Collection $comments + * @property Collection $fields + * @property Collection $members * @property Collection $statuses + * @property Collection $tasks + * @property Collection $taskTemplates + * @property Collection $views * @property float $orderindex - * @property integer $id - * @property integer $task_count + * @property Folder|null $folder + * @property int $id + * @property int $task_count * @property Member $assignee * @property Priority $priority + * @property Space|null $space * @property Status $status * @property string $content * @property string $name @@ -40,41 +46,35 @@ class TaskList extends Model * @var array */ protected $casts = [ - 'archived' => 'boolean', - 'due_date' => 'datetime:Uv', - 'due_date_time' => 'boolean', - 'id' => 'integer', - 'orderindex' => 'float', + 'archived' => 'boolean', + 'due_date' => 'datetime:Uv', + 'due_date_time' => 'boolean', + 'id' => 'integer', + 'orderindex' => 'float', 'override_statuses' => 'boolean', - 'start_date' => 'datetime:Uv', - 'start_date_time' => 'boolean', - 'task_count' => 'integer', + 'start_date' => 'datetime:Uv', + 'start_date_time' => 'boolean', + 'task_count' => 'integer', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/list'; + protected string $path = '/list'; /** * Some of the responses have the collections under a property - * - * @var string|null */ - protected $responseCollectionKey = 'lists'; + protected ?string $responseCollectionKey = 'lists'; /** * Some of the responses have the data under a property - * - * @var string|null */ - protected $responseKey = 'list'; + protected ?string $responseKey = 'list'; /** - * @return HasMany - + * Has many Comments + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -85,8 +85,8 @@ public function comments(): HasMany } /** - * @return HasMany - + * Has many Fields + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -97,7 +97,8 @@ public function fields(): HasMany } /** - * @return ChildOf + * Optional Child of Folder + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -110,12 +111,9 @@ public function folder(): ?ChildOf /** * Accessor for Assignee. * - * @param array $assignee - * - * @return Member * @throws NoClientException */ - public function getAssigneeAttribute($assignee): Member + public function getAssigneeAttribute(?array $assignee): Member { return $this->givenOne(Member::class, $assignee); } @@ -123,12 +121,9 @@ public function getAssigneeAttribute($assignee): Member /** * Accessor for Priority. * - * @param array $priority - * - * @return Priority * @throws NoClientException */ - public function getPriorityAttribute($priority): Priority + public function getPriorityAttribute(?array $priority): Priority { return $this->givenOne(Priority::class, $priority); } @@ -136,12 +131,9 @@ public function getPriorityAttribute($priority): Priority /** * Accessor for Status. * - * @param array $status - * - * @return Status * @throws NoClientException */ - public function getStatusAttribute($status): Status + public function getStatusAttribute(?array $status): Status { return $this->givenOne(Status::class, $status); } @@ -149,19 +141,16 @@ public function getStatusAttribute($status): Status /** * Accessor for Statuses. * - * @param array $statuses - * - * @return Collection * @throws NoClientException */ - public function getStatusesAttribute(array $statuses): Collection + public function getStatusesAttribute(?array $statuses): Collection { return $this->givenMany(Status::class, $statuses); } /** - * @return HasMany - + * Has many Members + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -172,7 +161,8 @@ public function members(): HasMany } /** - * @return ChildOf + * Optional Child of Space + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -183,8 +173,8 @@ public function space(): ?ChildOf } /** - * @return HasMany - + * Has many Tasks + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -195,8 +185,8 @@ public function tasks(): HasMany } /** - * @return HasMany - + * Has many TaskTemplates + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -207,8 +197,8 @@ public function taskTemplates(): HasMany } /** - * @return HasMany - + * Has many Views + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/TaskTemplate.php b/src/TaskTemplate.php index 57c72f8..e688598 100644 --- a/src/TaskTemplate.php +++ b/src/TaskTemplate.php @@ -7,8 +7,6 @@ /** * Class TaskTemplate * - * @package Spinen\ClickUp - * * @property string $id * @property string $name */ @@ -25,15 +23,11 @@ class TaskTemplate extends Model /** * Path to API endpoint. - * - * @var string */ - protected $path = '/taskTemplate'; + protected string $path = '/taskTemplate'; /** * Some of the responses have the collections under a property - * - * @var string|null */ - protected $responseCollectionKey = 'templates'; + protected ?string $responseCollectionKey = 'templates'; } diff --git a/src/Team.php b/src/Team.php index 6a81e9d..2207669 100644 --- a/src/Team.php +++ b/src/Team.php @@ -12,8 +12,6 @@ /** * Class Team * - * @package Spinen\ClickUp - * * @property Collection $goals * @property Collection $members * @property Collection $shares @@ -22,11 +20,10 @@ * @property Collection $taskTemplates * @property Collection $views * @property Collection $webhooks - * @property integer $id + * @property int $id * @property string $avatar * @property string $color * @property string $name - * */ class Team extends Model { @@ -41,37 +38,34 @@ class Team extends Model /** * Path to API endpoint. - * - * @var string */ - protected $path = '/team'; + protected string $path = '/team'; /** - * Accessor for Members. - * - * @param array $members + * Has many Goals * - * @return Collection + * @throws InvalidRelationshipException + * @throws ModelNotFoundException * @throws NoClientException */ - public function getMembersAttribute(array $members): Collection + public function goals(): HasMany { - return $this->givenMany(Member::class, $members, true); + return $this->hasMany(Goal::class); } /** - * @return HasMany - * @throws InvalidRelationshipException - * @throws ModelNotFoundException + * Accessor for Members. + * * @throws NoClientException */ - public function goals(): HasMany + public function getMembersAttribute(?array $members): Collection { - return $this->hasMany(Goal::class); + return $this->givenMany(Member::class, $members, true); } /** - * @return HasMany + * Has many Shares + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -82,7 +76,8 @@ public function shares(): HasMany } /** - * @return HasMany + * Has many Spaces + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -93,7 +88,8 @@ public function spaces(): HasMany } /** - * @return HasMany + * Has many Tasks + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -104,7 +100,8 @@ public function tasks(): HasMany } /** - * @return HasMany + * Has many TaskTemplates + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -115,7 +112,8 @@ public function taskTemplates(): HasMany } /** - * @return HasMany + * Has many Views + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -126,7 +124,8 @@ public function views(): HasMany } /** - * @return HasMany + * Has many Webhooks + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Time.php b/src/Time.php index f2fcd92..68b2759 100644 --- a/src/Time.php +++ b/src/Time.php @@ -12,10 +12,8 @@ /** * Class Time * - * @package Spinen\ClickUp - * * @property Collection $intervals - * @property integer $time + * @property int $time * @property Member $user * @property Task $task */ @@ -32,27 +30,20 @@ class Time extends Model /** * Path to API endpoint. - * - * @var string */ - protected $path = '/time'; + protected string $path = '/time'; /** * Some of the responses have the data under a property - * - * @var string|null */ - protected $responseKey = 'data'; + protected ?string $responseKey = 'data'; /** * Accessor for Intervals. * - * @param array $intervals - * - * @return Collection * @throws NoClientException */ - public function getIntervalsAttribute(array $intervals): Collection + public function getIntervalsAttribute(?array $intervals): Collection { return $this->givenMany(Interval::class, $intervals); } @@ -60,18 +51,16 @@ public function getIntervalsAttribute(array $intervals): Collection /** * Accessor for User. * - * @param array $user - * - * @return Member * @throws NoClientException */ - public function getUserAttribute($user): Member + public function getUserAttribute(?array $user): Member { return $this->givenOne(Member::class, $user); } /** - * @return ChildOf + * Child of Task + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/User.php b/src/User.php index 8b89d5e..efcbcab 100644 --- a/src/User.php +++ b/src/User.php @@ -7,11 +7,9 @@ /** * Class User * - * @package Spinen\ClickUp - * - * @property boolean $global_font_support - * @property integer $id - * @property integer $week_start_day + * @property bool $global_font_support + * @property int $id + * @property int $week_start_day * @property string $color * @property string $email * @property string $initials @@ -28,21 +26,17 @@ class User extends Model */ protected $casts = [ 'global_font_support' => 'boolean', - 'id' => 'integer', - 'week_start_day' => 'integer', + 'id' => 'integer', + 'week_start_day' => 'integer', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/user'; + protected string $path = '/user'; /** * Is the model readonly? - * - * @var bool */ - protected $readonlyModel = true; + protected bool $readonlyModel = true; } diff --git a/src/View.php b/src/View.php index 90d5053..240936e 100644 --- a/src/View.php +++ b/src/View.php @@ -13,8 +13,6 @@ /** * Class View * - * @package Spinen\ClickUp - * * @property array $columns * @property array $divide * @property array $filters @@ -23,17 +21,23 @@ * @property array $settings * @property array $sorting * @property array $team_sidebar - * @property boolean $protected + * @property bool $protected * @property Carbon $date_created * @property Carbon $date_protected + * @property Collection $comments + * @property Collection $tasks * @property float $orderindex - * @property integer $creator + * @property Folder|null $folder + * @property int $creator * @property Member $protected_by + * @property Space|null $space * @property string $id * @property string $name * @property string $protected_note * @property string $type * @property string $visibility + * @property TaskList|null $list + * @property Team|null $team */ class View extends Model { @@ -43,23 +47,21 @@ class View extends Model * @var array */ protected $casts = [ - 'date_created' => 'datetime:Uv', + 'date_created' => 'datetime:Uv', 'date_protected' => 'integer', - 'id' => 'string', - 'orderindex' => 'float', - 'protected' => 'boolean', + 'id' => 'string', + 'orderindex' => 'float', + 'protected' => 'boolean', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/view'; + protected string $path = '/view'; /** - * @return HasMany - + * Has many Comments + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -76,7 +78,8 @@ public function comments(): HasMany } /** - * @return ChildOf + * Optional Child of Folder + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -89,18 +92,16 @@ public function folder(): ?ChildOf /** * Accessor for ProtectedBy. * - * @param array $protected_by - * - * @return Member * @throws NoClientException */ - public function getProtectedByAttribute($protected_by): Member + public function getProtectedByAttribute(?array $protected_by): Member { return $this->givenOne(Member::class, $protected_by); } /** - * @return ChildOf + * Optional Child of TaskList + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -111,7 +112,8 @@ public function list(): ?ChildOf } /** - * @return ChildOf + * Optional Child of Space + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -122,8 +124,8 @@ public function space(): ?ChildOf } /** - * @return HasMany - + * HasMany Tasks + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -140,7 +142,8 @@ public function tasks(): HasMany } /** - * @return ChildOf + * Optional Child of Team + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/src/Webhook.php b/src/Webhook.php index 5ced39b..fb36545 100644 --- a/src/Webhook.php +++ b/src/Webhook.php @@ -12,15 +12,18 @@ /** * Class Webhook * - * @package Spinen\ClickUp - * * @property array $events - * @property integer $folder_id - * @property integer $list_id - * @property integer $space_id - * @property integer $team_id - * @property integer $userid + * @property Folder $folder + * @property int $folder_id + * @property int $list_id + * @property int $space_id + * @property int $team_id + * @property int $userid + * @property Member $user + * @property Space #space * @property string $id + * @property TaskList $list + * @property Team $team */ class Webhook extends Model { @@ -31,23 +34,21 @@ class Webhook extends Model */ protected $casts = [ 'folder_id' => 'integer', - 'id' => 'string', - 'list_id' => 'integer', - 'space_id' => 'integer', - 'team_id' => 'integer', - 'userid' => 'integer', + 'id' => 'string', + 'list_id' => 'integer', + 'space_id' => 'integer', + 'team_id' => 'integer', + 'userid' => 'integer', ]; /** * Path to API endpoint. - * - * @var string */ - protected $path = '/webhook'; + protected string $path = '/webhook'; /** - * @return BelongsTo - + * Belongs to Folder + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -58,7 +59,8 @@ public function folder(): BelongsTo } /** - * @return BelongsTo + * Belongs to TaskList + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -69,7 +71,8 @@ public function list(): BelongsTo } /** - * @return BelongsTo + * Belongs to Space + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -80,7 +83,8 @@ public function space(): BelongsTo } /** - * @return ChildOf + * Child of Team + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException @@ -91,7 +95,8 @@ public function team(): ChildOf } /** - * @return BelongsTo + * Belongs to Member + * * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/tests/Api/ClientTest.php b/tests/Api/ClientTest.php index 7d83b6c..eb43234 100644 --- a/tests/Api/ClientTest.php +++ b/tests/Api/ClientTest.php @@ -15,8 +15,6 @@ /** * Class ClientTest - * - * @package Spinen\ClickUp\Api */ class ClientTest extends TestCase { @@ -52,11 +50,10 @@ class ClientTest extends TestCase protected function setUp(): void { - $this->configs = require(__DIR__ . '/../../config/clickup.php'); + $this->configs = require __DIR__.'/../../config/clickup.php'; $this->guzzle_mock = Mockery::mock(Guzzle::class); - $this->stream_interface_mock = Mockery::mock(StreamInterface::class); $this->stream_interface_mock->shouldReceive('getContents') ->withNoArgs() @@ -171,7 +168,7 @@ public function it_sets_url_to_default_value_if_its_an_empty_string() { $this->client->setConfigs( [ - 'url' => "", + 'url' => '', ] ); @@ -242,6 +239,7 @@ public function it_builds_correct_uri() /** * @test + * * @dataProvider requestProvider */ public function it_makes_expected_request_to_api($function, $method, $data, $parameter = null) @@ -253,13 +251,13 @@ public function it_makes_expected_request_to_api($function, $method, $data, $par ->withArgs( [ $method, - $this->configs['url'] . '/resource', + $this->configs['url'].'/resource', [ 'headers' => [ 'Authorization' => $token, - 'Content-Type' => 'application/json', + 'Content-Type' => 'application/json', ], - 'body' => empty($options) ? null : json_encode($options), + 'body' => empty($options) ? null : json_encode($options), ], ] ) @@ -282,29 +280,29 @@ public function requestProvider() return [ 'raw request' => [ 'function' => 'request', - 'method' => 'GET', - 'data' => [], + 'method' => 'GET', + 'data' => [], ], - 'delete' => [ + 'delete' => [ 'function' => 'delete', - 'method' => 'DELETE', - 'data' => [], + 'method' => 'DELETE', + 'data' => [], ], - 'get' => [ + 'get' => [ 'function' => 'get', - 'method' => 'GET', - 'data' => null, + 'method' => 'GET', + 'data' => null, ], - 'post' => [ - 'function' => 'post', - 'method' => 'POST', - 'data' => [], + 'post' => [ + 'function' => 'post', + 'method' => 'POST', + 'data' => [], 'parameter' => [], ], - 'put' => [ - 'function' => 'put', - 'method' => 'PUT', - 'data' => [], + 'put' => [ + 'function' => 'put', + 'method' => 'PUT', + 'data' => [], 'parameter' => [], ], ]; @@ -328,6 +326,7 @@ public function it_raises_exception_when_guzzle_error() /** * @test + * * @dataProvider responseProvider */ public function it_returns_expected_responses($json, $expected) @@ -357,26 +356,26 @@ public function it_returns_expected_responses($json, $expected) public function responseProvider() { return [ - 'null' => [ - 'json' => 'null', + 'null' => [ + 'json' => 'null', 'expected' => null, ], 'empty_object' => [ - 'json' => '{}', + 'json' => '{}', 'expected' => [], ], - 'empty_array' => [ - 'json' => '[]', + 'empty_array' => [ + 'json' => '[]', 'expected' => [], ], - 'object' => [ - 'json' => '{"some": "key"}', + 'object' => [ + 'json' => '{"some": "key"}', 'expected' => [ 'some' => 'key', ], ], - 'array' => [ - 'json' => '[{"some": 1}, {"some": 2}]', + 'array' => [ + 'json' => '[{"some": 1}, {"some": 2}]', 'expected' => [ [ 'some' => 1, @@ -438,7 +437,7 @@ public function it_will_swap_oauth_code_for_token() ->withArgs( [ 'POST', - $this->configs['url'] . + $this->configs['url']. '/oauth/token?client_id=client_id&client_secret=client_secret&code=oauth_code', [ 'headers' => [ diff --git a/tests/ChecklistTest.php b/tests/ChecklistTest.php index 22332a1..490a20e 100644 --- a/tests/ChecklistTest.php +++ b/tests/ChecklistTest.php @@ -7,8 +7,6 @@ /** * Class BuilderTest - * - * @package Spinen\ClickUp */ class ChecklistTest extends ModelCase { diff --git a/tests/CommentTest.php b/tests/CommentTest.php index 7be6287..de7251c 100644 --- a/tests/CommentTest.php +++ b/tests/CommentTest.php @@ -6,8 +6,6 @@ /** * Class CommentTest - * - * @package Spinen\ClickUp */ class CommentTest extends ModelCase { diff --git a/tests/Concerns/HasClickUpTest.php b/tests/Concerns/HasClickUpTest.php index 7b91e36..aa1cec0 100644 --- a/tests/Concerns/HasClickUpTest.php +++ b/tests/Concerns/HasClickUpTest.php @@ -3,7 +3,7 @@ namespace Spinen\ClickUp\Concerns; use Illuminate\Container\Container; -use Illuminate\Contracts\Encryption\Encrypter; +use Illuminate\Support\Facades\Crypt; use Mockery; use Mockery\Mock; use ReflectionClass; @@ -40,35 +40,30 @@ protected function setUp(): void $this->client_mock = Mockery::mock(ClickUp::class); $this->client_mock->shouldReceive('setToken') - ->withArgs( - [ - Mockery::any(), - ] - ) - ->andReturnSelf(); + ->withArgs( + [ + Mockery::any(), + ] + ) + ->andReturnSelf(); $this->builder_mock = Mockery::mock(Builder::class); $this->builder_mock->shouldReceive('getClient') - ->withNoArgs() - ->andReturn($this->client_mock); + ->withNoArgs() + ->andReturn($this->client_mock); $this->builder_mock->shouldReceive('setClient') - ->withArgs( - [ - $this->client_mock, - ] - ) - ->andReturnSelf(); - - $this->encrypter_mock = Mockery::mock(Encrypter::class); - - Container::getInstance() - ->instance(Builder::class, $this->builder_mock); + ->withArgs( + [ + $this->client_mock, + ] + ) + ->andReturnSelf(); Container::getInstance() - ->instance(ClickUp::class, $this->client_mock); + ->instance(Builder::class, $this->builder_mock); Container::getInstance() - ->instance(Encrypter::class, $this->encrypter_mock); + ->instance(ClickUp::class, $this->client_mock); } /** @@ -127,10 +122,10 @@ public function it_has_an_accessor_to_get_the_client() */ public function it_has_an_accessor_to_decrypt_clickup_token() { - $this->encrypter_mock->shouldReceive('decrypt') - ->once() - ->with($this->trait->attributes['clickup_token']) - ->andReturn('decrypted'); + Crypt::shouldReceive('decryptString') + ->once() + ->with($this->trait->attributes['clickup_token']) + ->andReturn('decrypted'); $this->trait->getClickupTokenAttribute(); } @@ -142,11 +137,11 @@ public function it_does_not_try_to_decrypt_null_clickup_token() { $this->trait->attributes['clickup_token'] = null; - $this->encrypter_mock->shouldReceive('decrypt') - ->never() - ->withAnyArgs(); + Crypt::shouldReceive('decryptString') + ->never() + ->withAnyArgs(); - $this->trait->getClickupTokenAttribute(); + $this->assertNull($this->trait->getClickupTokenAttribute()); } /** @@ -154,16 +149,18 @@ public function it_does_not_try_to_decrypt_null_clickup_token() */ public function it_has_mutator_to_encypt_clickup_token() { - $this->encrypter_mock->shouldReceive('encrypt') - ->once() - ->withArgs( - [ - 'unencrypted', - ] - ) - ->andReturn('encrypted'); + Crypt::shouldReceive('encryptString') + ->once() + ->withArgs( + [ + 'unencrypted', + ] + ) + ->andReturn('encrypted'); $this->trait->setClickupTokenAttribute('unencrypted'); + + $this->assertEquals('encrypted', $this->trait->attributes['clickup_token']); } /** @@ -171,11 +168,13 @@ public function it_has_mutator_to_encypt_clickup_token() */ public function it_does_not_mutate_a_null_clickup_token() { - $this->encrypter_mock->shouldReceive('encrypt') - ->never() - ->withAnyArgs(); + Crypt::shouldReceive('encryptString') + ->never() + ->withAnyArgs(); $this->trait->setClickupTokenAttribute(null); + + $this->assertNull($this->trait->attributes['clickup_token']); } /** @@ -183,8 +182,8 @@ public function it_does_not_mutate_a_null_clickup_token() */ public function it_invalidates_builder_cache_when_setting_clickup_token() { - $this->encrypter_mock->shouldReceive('encrypt') - ->withAnyArgs(); + Crypt::shouldReceive('encryptString') + ->withAnyArgs(); // Force cache $this->trait->clickup(); diff --git a/tests/Concerns/HasClientTest.php b/tests/Concerns/HasClientTest.php index 32b45d5..c531fe6 100644 --- a/tests/Concerns/HasClientTest.php +++ b/tests/Concerns/HasClientTest.php @@ -13,7 +13,6 @@ class HasClientTest extends TestCase { - /** * @var Mock */ diff --git a/tests/Concerns/Stubs/User.php b/tests/Concerns/Stubs/User.php index 1c18ffd..5824e92 100644 --- a/tests/Concerns/Stubs/User.php +++ b/tests/Concerns/Stubs/User.php @@ -11,7 +11,9 @@ class User public $attributes = [ 'clickup_token' => 'encrypted', ]; + public $fillable = []; + public $hidden = []; /** diff --git a/tests/FieldTest.php b/tests/FieldTest.php index 4030e22..2e6ccc9 100644 --- a/tests/FieldTest.php +++ b/tests/FieldTest.php @@ -6,8 +6,6 @@ /** * Class FieldTest - * - * @package Spinen\ClickUp */ class FieldTest extends ModelCase { diff --git a/tests/FolderTest.php b/tests/FolderTest.php index cdd5129..d441620 100644 --- a/tests/FolderTest.php +++ b/tests/FolderTest.php @@ -8,8 +8,6 @@ /** * Class FolderTest - * - * @package Spinen\ClickUp */ class FolderTest extends ModelCase { diff --git a/tests/GoalTest.php b/tests/GoalTest.php index 7282134..6df0c78 100644 --- a/tests/GoalTest.php +++ b/tests/GoalTest.php @@ -8,8 +8,6 @@ /** * Class GoalTest - * - * @package Spinen\ClickUp */ class GoalTest extends ModelCase { diff --git a/tests/Http/Controllers/ClickUpControllerTest.php b/tests/Http/Controllers/ClickUpControllerTest.php index ddfe3ee..152231a 100644 --- a/tests/Http/Controllers/ClickUpControllerTest.php +++ b/tests/Http/Controllers/ClickUpControllerTest.php @@ -23,6 +23,11 @@ class ClickUpControllerTest extends TestCase */ protected $controller; + /** + * @var Mock + */ + protected $redirect_mock; + /** * @var Mock */ @@ -42,8 +47,14 @@ protected function setUp(): void { $this->clickup_mock = Mockery::mock(ClickUp::class); + $this->redirect_mock = Mockery::mock(RedirectResponse::class); + $this->redirector_mock = Mockery::mock(Redirector::class); + $this->redirector_mock->shouldReceive('intended') + ->withNoArgs() + ->andReturn($this->redirect_mock); + $this->request_mock = Mockery::mock(Request::class); $this->user_mock = Mockery::mock(User::class); @@ -84,8 +95,6 @@ public function it_has_the_client_convert_code_to_token() $this->user_mock->shouldIgnoreMissing(); - $this->redirector_mock->shouldIgnoreMissing(); - $this->controller->processCode( $this->clickup_mock, $this->redirector_mock, @@ -121,8 +130,6 @@ public function it_saves_the_users_clickup_token_to_the_oauth_token() ->once() ->andReturn('oauth_token'); - $this->redirector_mock->shouldIgnoreMissing(); - $this->controller->processCode( $this->clickup_mock, $this->redirector_mock, @@ -144,13 +151,6 @@ public function it_redirects_the_user_to_the_intended_route() $this->user_mock->shouldIgnoreMissing(); - $redirect_mock = Mockery::mock(RedirectResponse::class); - - $this->redirector_mock->shouldReceive('intended') - ->once() - ->withNoArgs() - ->andReturn($redirect_mock); - $response = $this->controller->processCode( $this->clickup_mock, $this->redirector_mock, @@ -158,6 +158,6 @@ public function it_redirects_the_user_to_the_intended_route() $this->user_mock ); - $this->assertEquals($redirect_mock, $response); + $this->assertEquals($this->redirect_mock, $response); } } diff --git a/tests/Http/Middleware/FilterTest.php b/tests/Http/Middleware/FilterTest.php index fb2d326..03962cf 100644 --- a/tests/Http/Middleware/FilterTest.php +++ b/tests/Http/Middleware/FilterTest.php @@ -14,8 +14,6 @@ /** * Class FilterTest - * - * @package Spinen\ClickUp\Http\Middleware */ class FilterTest extends TestCase { @@ -54,9 +52,6 @@ class FilterTest extends TestCase */ protected $user_mock; - /** - * - */ protected function setUp(): void { $this->clickup_mock = Mockery::mock(ClickUp::class); @@ -211,7 +206,7 @@ public function it_redirects_user_to_correct_uri_if_it_does_not_have_a_clickup_t /** * Mock out the models setAttribute and getAttribute mutators with the given token * - * @param string|null $token + * @param string|null $token */ protected function mockUserAttributeMutators($token = null): void { diff --git a/tests/IntervalTest.php b/tests/IntervalTest.php index 5025fdc..828bacf 100644 --- a/tests/IntervalTest.php +++ b/tests/IntervalTest.php @@ -4,8 +4,6 @@ /** * Class IntervalTest - * - * @package Spinen\ClickUp */ class IntervalTest extends ModelCase { diff --git a/tests/ItemTest.php b/tests/ItemTest.php index ca2a0d7..e43f499 100644 --- a/tests/ItemTest.php +++ b/tests/ItemTest.php @@ -6,8 +6,6 @@ /** * Class ItemTest - * - * @package Spinen\ClickUp */ class ItemTest extends ModelCase { diff --git a/tests/MemberTest.php b/tests/MemberTest.php index 47bf5e4..52b75f4 100644 --- a/tests/MemberTest.php +++ b/tests/MemberTest.php @@ -6,8 +6,6 @@ /** * Class MemberTest - * - * @package Spinen\ClickUp */ class MemberTest extends ModelCase { diff --git a/tests/PriorityTest.php b/tests/PriorityTest.php index 1e0f6fb..db30f88 100644 --- a/tests/PriorityTest.php +++ b/tests/PriorityTest.php @@ -4,8 +4,6 @@ /** * Class PriorityTest - * - * @package Spinen\ClickUp */ class PriorityTest extends ModelCase { diff --git a/tests/ProjectTest.php b/tests/ProjectTest.php index 47a4bb1..b6bffd8 100644 --- a/tests/ProjectTest.php +++ b/tests/ProjectTest.php @@ -4,8 +4,6 @@ /** * Class ProjectTest - * - * @package Spinen\ClickUp */ class ProjectTest extends ModelCase { diff --git a/tests/ResultTest.php b/tests/ResultTest.php index b086996..b1c19c5 100644 --- a/tests/ResultTest.php +++ b/tests/ResultTest.php @@ -7,8 +7,6 @@ /** * Class ResultTest - * - * @package Spinen\ClickUp */ class ResultTest extends ModelCase { diff --git a/tests/ShareTest.php b/tests/ShareTest.php index 34dac83..ff08f46 100644 --- a/tests/ShareTest.php +++ b/tests/ShareTest.php @@ -7,8 +7,6 @@ /** * Class ShareTest - * - * @package Spinen\ClickUp */ class ShareTest extends ModelCase { diff --git a/tests/SpaceTest.php b/tests/SpaceTest.php index 1e103f6..2926867 100644 --- a/tests/SpaceTest.php +++ b/tests/SpaceTest.php @@ -8,8 +8,6 @@ /** * Class SpaceTest - * - * @package Spinen\ClickUp */ class SpaceTest extends ModelCase { diff --git a/tests/StatusTest.php b/tests/StatusTest.php index 00e12e1..5f1762e 100644 --- a/tests/StatusTest.php +++ b/tests/StatusTest.php @@ -4,8 +4,6 @@ /** * Class StatusTest - * - * @package Spinen\ClickUp */ class StatusTest extends ModelCase { diff --git a/tests/Support/BuilderTest.php b/tests/Support/BuilderTest.php index ff29825..0da3985 100644 --- a/tests/Support/BuilderTest.php +++ b/tests/Support/BuilderTest.php @@ -17,8 +17,6 @@ /** * Class BuilderTest - * - * @package Spinen\ClickUp\Support */ class BuilderTest extends TestCase { @@ -38,13 +36,13 @@ class BuilderTest extends TestCase protected $team_response = [ [ 'color' => '#000000', - 'id' => 1, - 'name' => 'Team 1', + 'id' => 1, + 'name' => 'Team 1', ], [ 'color' => '#ffffff', - 'id' => 2, - 'name' => 'Team 2', + 'id' => 2, + 'name' => 'Team 2', ], ]; @@ -66,6 +64,7 @@ public function it_can_be_constructed() /** * @test + * * @dataProvider rootModels */ public function it_returns_builder_for_root_models($model) @@ -82,13 +81,13 @@ public function it_returns_builder_for_root_models($model) public function rootModels() { return [ - 'spaces' => [ + 'spaces' => [ 'model' => 'spaces', ], - 'tasks' => [ + 'tasks' => [ 'model' => 'tasks', ], - 'teams' => [ + 'teams' => [ 'model' => 'teams', ], 'workspaces' => [ diff --git a/tests/Support/CollectionTest.php b/tests/Support/CollectionTest.php index 7ef105a..2e957cc 100644 --- a/tests/Support/CollectionTest.php +++ b/tests/Support/CollectionTest.php @@ -6,8 +6,6 @@ /** * Class CollectionTestTest - * - * @package Spinen\ClickUp\Support */ class CollectionTest extends TestCase { diff --git a/tests/Support/ModelTest.php b/tests/Support/ModelTest.php index 86dbb9c..d826b02 100644 --- a/tests/Support/ModelTest.php +++ b/tests/Support/ModelTest.php @@ -22,10 +22,8 @@ /** * Class ModelTest - * - * @package Spinen\ClickUp\Support */ -class ModelTestTest extends TestCase +class ModelTest extends TestCase { /** * @var Mock @@ -135,7 +133,7 @@ public function it_raises_exception_when_setting_array_key_on_readonly_model() */ public function it_cast_the_model_as_json_when_used_as_a_string() { - $this->assertJson((string)$this->model); + $this->assertJson((string) $this->model); } /** @@ -682,7 +680,7 @@ public function it_will_post_when_saving_and_put_when_updating_a_model() ) ->andReturn( [ - 'id' => 1, + 'id' => 1, 'some' => 'property', ] ); @@ -699,8 +697,8 @@ public function it_will_post_when_saving_and_put_when_updating_a_model() ) ->andReturn( [ - 'id' => 1, - 'some' => 'changed', + 'id' => 1, + 'some' => 'changed', 'updated' => true, ] ); @@ -777,49 +775,50 @@ public function castToDatetimeValuesProvider() { $carbon = Carbon::now(); $datetime = new DateTime(); + return [ - 'carbon' => [ - 'value' => $carbon, + 'carbon' => [ + 'value' => $carbon, 'timestampsInMilliseconds' => true, - 'expected' => Date::instance($carbon), + 'expected' => Date::instance($carbon), ], - 'datetime' => [ - 'value' => $datetime, + 'datetime' => [ + 'value' => $datetime, 'timestampsInMilliseconds' => true, - 'expected' => Date::parse($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone()), + 'expected' => Date::parse($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone()), ], - 'carbon2' => [ - 'value' => $carbon, + 'carbon2' => [ + 'value' => $carbon, 'timestampsInMilliseconds' => false, - 'expected' => Date::instance($carbon), + 'expected' => Date::instance($carbon), ], - 'datetime2' => [ - 'value' => $datetime, + 'datetime2' => [ + 'value' => $datetime, 'timestampsInMilliseconds' => false, - 'expected' => Date::parse($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone()), + 'expected' => Date::parse($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone()), ], - 'timestamp' => [ - 'value' => 1579542588, + 'timestamp' => [ + 'value' => 1579542588, 'timestampsInMilliseconds' => false, - 'expected' => Date::createFromTimestamp(1579542588), + 'expected' => Date::createFromTimestamp(1579542588), ], 'timestamp_ms' => [ - 'value' => 1579542588123, + 'value' => 1579542588123, 'timestampsInMilliseconds' => true, - 'expected' => Date::createFromTimestampMs(1579542588123), + 'expected' => Date::createFromTimestampMs(1579542588123), ], - 'standard_ms' => [ - 'value' => '2020-02-01', + 'standard_ms' => [ + 'value' => '2020-02-01', 'timestampsInMilliseconds' => true, - 'expected' => Date::instance( + 'expected' => Date::instance( Carbon::createFromFormat('Y-m-d', '2020-02-01') ->startOfDay() ), ], - 'standard' => [ - 'value' => '2020-02-01', + 'standard' => [ + 'value' => '2020-02-01', 'timestampsInMilliseconds' => false, - 'expected' => Date::instance( + 'expected' => Date::instance( Carbon::createFromFormat('Y-m-d', '2020-02-01') ->startOfDay() ), @@ -829,6 +828,7 @@ public function castToDatetimeValuesProvider() /** * @test + * * @dataProvider castToDatetimeValuesProvider */ public function it_casts_to_datetime_from_various_values($value, $timestampInMilliseconds, $expected) diff --git a/tests/Support/Relations/BelongsToTest.php b/tests/Support/Relations/BelongsToTest.php index fd6613f..e4c2dae 100644 --- a/tests/Support/Relations/BelongsToTest.php +++ b/tests/Support/Relations/BelongsToTest.php @@ -4,6 +4,7 @@ use Mockery; use Spinen\ClickUp\Support\Builder; +use Spinen\ClickUp\Support\Collection; use Spinen\ClickUp\Support\Stubs\Model; class BelongsToTest extends RelationCase @@ -33,7 +34,6 @@ protected function setUp(): void ) ->andReturn(1); - $this->relation = new BelongsTo($this->builder_mock, $this->model_mock, 'id'); } @@ -82,7 +82,7 @@ public function it_gets_the_first_value_from_the_results_of_the_builder() $this->builder_mock->shouldReceive('get') ->once() ->withNoArgs() - ->andReturn(collect($results)); + ->andReturn(Collection::make($results)); $results = $this->relation->getResults(); @@ -116,7 +116,6 @@ public function it_returns_null_if_foreign_key_is_null() ) ->andReturn(null); - $this->relation = new BelongsTo($builder_mock, $model_mock, 'id'); $this->assertNull($this->relation->getResults()); diff --git a/tests/Support/Relations/ChildOfTest.php b/tests/Support/Relations/ChildOfTest.php index cb92247..6cc6395 100644 --- a/tests/Support/Relations/ChildOfTest.php +++ b/tests/Support/Relations/ChildOfTest.php @@ -2,10 +2,6 @@ namespace Spinen\ClickUp\Support\Relations; -use Mockery; -use Spinen\ClickUp\Support\Builder; -use Spinen\ClickUp\Support\Stubs\Model; - class ChildOfTest extends RelationCase { /** diff --git a/tests/Support/Relations/HasManyTest.php b/tests/Support/Relations/HasManyTest.php index 4950bc0..dac5cf7 100644 --- a/tests/Support/Relations/HasManyTest.php +++ b/tests/Support/Relations/HasManyTest.php @@ -2,7 +2,6 @@ namespace Spinen\ClickUp\Support\Relations; -use Mockery; use Spinen\ClickUp\Support\Collection; class HasManyTest extends RelationCase diff --git a/tests/Support/Relations/RelationCase.php b/tests/Support/Relations/RelationCase.php index 1001bbd..a31132e 100644 --- a/tests/Support/Relations/RelationCase.php +++ b/tests/Support/Relations/RelationCase.php @@ -6,7 +6,6 @@ use Mockery\Mock; use Spinen\ClickUp\Support\Builder; use Spinen\ClickUp\Support\Model; -use Spinen\ClickUp\Support\Relations\Stubs\Relation; use Spinen\ClickUp\TestCase; class RelationCase extends TestCase diff --git a/tests/Support/Relations/Stubs/Relation.php b/tests/Support/Relations/Stubs/Relation.php index 9a0684b..5959988 100644 --- a/tests/Support/Relations/Stubs/Relation.php +++ b/tests/Support/Relations/Stubs/Relation.php @@ -8,8 +8,6 @@ class Relation extends BaseRelation { /** * Get the results of the relationship. - * - * @return mixed */ public function getResults() { diff --git a/tests/Support/Stubs/Model.php b/tests/Support/Stubs/Model.php index 695fe13..03ff3de 100644 --- a/tests/Support/Stubs/Model.php +++ b/tests/Support/Stubs/Model.php @@ -13,19 +13,15 @@ class Model extends BaseModel { /** * Path to API endpoint. - * - * @var string */ - protected $path = 'some/path'; + protected string $path = 'some/path'; /** * Mutator for Mutator. - * - * @param $value */ public function setMutatorAttribute($value) { - $this->attributes['mutator'] = 'mutated: ' . $value; + $this->attributes['mutator'] = 'mutated: '.$value; } public function setResponseCollectionKey($key) @@ -40,12 +36,8 @@ public function setResponseKey($key) /** * Allow swapping nested for test - * - * @param $nested - * - * @return Model */ - public function setNested($nested) + public function setNested($nested): Model { $this->nested = $nested; @@ -53,7 +45,6 @@ public function setNested($nested) } /** - * @return HasMany * @throws InvalidRelationshipException * @throws ModelNotFoundException * @throws NoClientException diff --git a/tests/TagTest.php b/tests/TagTest.php index d8b0041..1ab49f2 100644 --- a/tests/TagTest.php +++ b/tests/TagTest.php @@ -6,8 +6,6 @@ /** * Class TagTest - * - * @package Spinen\ClickUp */ class TagTest extends ModelCase { diff --git a/tests/TaskListTest.php b/tests/TaskListTest.php index aaa4699..3552bf9 100644 --- a/tests/TaskListTest.php +++ b/tests/TaskListTest.php @@ -8,8 +8,6 @@ /** * Class TaskListTest - * - * @package Spinen\ClickUp */ class TaskListTest extends ModelCase { diff --git a/tests/TaskTemplateTest.php b/tests/TaskTemplateTest.php index 803fa83..bba69bc 100644 --- a/tests/TaskTemplateTest.php +++ b/tests/TaskTemplateTest.php @@ -4,8 +4,6 @@ /** * Class TaskTemplateTest - * - * @package Spinen\ClickUp */ class TaskTemplateTest extends ModelCase { diff --git a/tests/TaskTest.php b/tests/TaskTest.php index cb0fc23..f231d47 100644 --- a/tests/TaskTest.php +++ b/tests/TaskTest.php @@ -9,8 +9,6 @@ /** * Class TaskTest - * - * @package Spinen\ClickUp */ class TaskTest extends ModelCase { diff --git a/tests/TeamTest.php b/tests/TeamTest.php index ba22e0f..48e4f8b 100644 --- a/tests/TeamTest.php +++ b/tests/TeamTest.php @@ -7,8 +7,6 @@ /** * Class TeamTest - * - * @package Spinen\ClickUp */ class TeamTest extends ModelCase { diff --git a/tests/TestCase.php b/tests/TestCase.php index fc6d047..b3a0155 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,8 +11,6 @@ /** * Class TestCase - * - * @package Tests\Spinen\ClickUp */ abstract class TestCase extends PHPUnitTestCase { @@ -23,9 +21,6 @@ abstract class TestCase extends PHPUnitTestCase * * @link https://gist.github.com/VladaHejda/8299871 * - * @param MockInterface $mock - * @param array $items - * * @return void */ protected function mockArrayIterator(MockInterface $mock, array $items) @@ -49,7 +44,7 @@ protected function mockArrayIterator(MockInterface $mock, array $items) $counter = 0; $mock->shouldReceive('rewind') - ->andReturnUsing(function () use (& $counter) { + ->andReturnUsing(function () use (&$counter) { $counter = 0; }); @@ -57,23 +52,23 @@ protected function mockArrayIterator(MockInterface $mock, array $items) $keys = array_values(array_keys($items)); $mock->shouldReceive('valid') - ->andReturnUsing(function () use (& $counter, $vals) { + ->andReturnUsing(function () use (&$counter, $vals) { return isset($vals[$counter]); }); $mock->shouldReceive('current') - ->andReturnUsing(function () use (& $counter, $vals) { + ->andReturnUsing(function () use (&$counter, $vals) { return $vals[$counter]; }); $mock->shouldReceive('key') - ->andReturnUsing(function () use (& $counter, $keys) { + ->andReturnUsing(function () use (&$counter, $keys) { return $keys[$counter]; }); $mock->shouldReceive('next') - ->andReturnUsing(function () use (& $counter) { - ++$counter; + ->andReturnUsing(function () use (&$counter) { + $counter++; }); } diff --git a/tests/TimeTest.php b/tests/TimeTest.php index 8ac4e18..4c3d517 100644 --- a/tests/TimeTest.php +++ b/tests/TimeTest.php @@ -7,8 +7,6 @@ /** * Class TimeTest - * - * @package Spinen\ClickUp */ class TimeTest extends ModelCase { diff --git a/tests/ViewTest.php b/tests/ViewTest.php index ee248f0..d94e374 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -8,8 +8,6 @@ /** * Class ViewTest - * - * @package Spinen\ClickUp */ class ViewTest extends ModelCase { diff --git a/tests/WebhookTest.php b/tests/WebhookTest.php index c881917..37e02c4 100644 --- a/tests/WebhookTest.php +++ b/tests/WebhookTest.php @@ -6,8 +6,6 @@ /** * Class WebhookTest - * - * @package Spinen\ClickUp */ class WebhookTest extends ModelCase {