1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the zibios/wrike-php-library package. |
7
|
|
|
* |
8
|
|
|
* (c) Zbigniew Ślązak |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Zibios\WrikePhpLibrary\Resource; |
15
|
|
|
|
16
|
|
|
use Zibios\WrikePhpLibrary\Enum\Api\RequestPathFormatEnum; |
17
|
|
|
use Zibios\WrikePhpLibrary\Enum\Api\ResourceMethodEnum; |
18
|
|
|
use Zibios\WrikePhpLibrary\Resource\Traits\CreateForTaskTrait; |
19
|
|
|
use Zibios\WrikePhpLibrary\Resource\Traits\DeleteTrait; |
20
|
|
|
use Zibios\WrikePhpLibrary\Resource\Traits\GetAllForTaskTrait; |
21
|
|
|
use Zibios\WrikePhpLibrary\Resource\Traits\GetByIdsTrait; |
22
|
|
|
use Zibios\WrikePhpLibrary\Resource\Traits\GetByIdTrait; |
23
|
|
|
use Zibios\WrikePhpLibrary\Resource\Traits\UpdateTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Dependency Resource. |
27
|
|
|
*/ |
28
|
|
|
class DependencyResource extends AbstractResource |
29
|
|
|
{ |
30
|
|
|
use GetAllForTaskTrait; |
31
|
|
|
use GetByIdTrait; |
32
|
|
|
use GetByIdsTrait; |
33
|
|
|
use CreateForTaskTrait; |
34
|
|
|
use UpdateTrait; |
35
|
|
|
use DeleteTrait; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Return connection array ResourceMethod => RequestPathFormat. |
39
|
|
|
* |
40
|
|
|
* @see \Zibios\WrikePhpLibrary\Enum\Api\ResourceMethodEnum |
41
|
|
|
* @see \Zibios\WrikePhpLibrary\Enum\Api\RequestPathFormatEnum |
42
|
|
|
* |
43
|
|
|
* @return array |
44
|
|
|
*/ |
45
|
6 |
View Code Duplication |
protected function getResourceMethodConfiguration(): array |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
6 |
|
ResourceMethodEnum::GET_ALL_FOR_TASK => RequestPathFormatEnum::DEPENDENCIES_FOR_TASK, |
49
|
|
|
ResourceMethodEnum::GET_BY_ID => RequestPathFormatEnum::DEPENDENCIES_BY_ID, |
50
|
|
|
ResourceMethodEnum::GET_BY_IDS => RequestPathFormatEnum::DEPENDENCIES_BY_IDS, |
51
|
|
|
ResourceMethodEnum::CREATE_FOR_TASK => RequestPathFormatEnum::DEPENDENCIES_FOR_TASK, |
52
|
|
|
ResourceMethodEnum::UPDATE => RequestPathFormatEnum::DEPENDENCIES_BY_ID, |
53
|
|
|
ResourceMethodEnum::DELETE => RequestPathFormatEnum::DEPENDENCIES_BY_ID, |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.