GroupResource   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 27
loc 27
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getResourceMethodConfiguration() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\CreateTrait;
19
use Zibios\WrikePhpLibrary\Resource\Traits\DeleteTrait;
20
use Zibios\WrikePhpLibrary\Resource\Traits\GetAllTrait;
21
use Zibios\WrikePhpLibrary\Resource\Traits\GetByIdTrait;
22
use Zibios\WrikePhpLibrary\Resource\Traits\UpdateTrait;
23
24
/**
25
 * Group Resource.
26
 */
27 View Code Duplication
class GroupResource extends AbstractResource
28
{
29
    use GetAllTrait;
30
    use GetByIdTrait;
31
    use CreateTrait;
32
    use UpdateTrait;
33
    use DeleteTrait;
34
35
    /**
36
     * Return connection array ResourceMethod => RequestPathFormat.
37
     *
38
     * @see \Zibios\WrikePhpLibrary\Enum\Api\ResourceMethodEnum
39
     * @see \Zibios\WrikePhpLibrary\Enum\Api\RequestPathFormatEnum
40
     *
41
     * @return array
42
     */
43 5
    protected function getResourceMethodConfiguration(): array
44
    {
45
        return [
46 5
            ResourceMethodEnum::GET_ALL => RequestPathFormatEnum::GROUPS,
47
            ResourceMethodEnum::GET_BY_ID => RequestPathFormatEnum::GROUPS_BY_ID,
48
            ResourceMethodEnum::CREATE => RequestPathFormatEnum::GROUPS,
49
            ResourceMethodEnum::UPDATE => RequestPathFormatEnum::GROUPS_BY_ID,
50
            ResourceMethodEnum::DELETE => RequestPathFormatEnum::GROUPS_BY_ID,
51
        ];
52
    }
53
}
54