ProjectsResource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 47
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A listProjects() 0 5 1
A getProject() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
namespace VictorAvelar\Phraseapp\Resources;
4
5
use GuzzleHttp\Exception\GuzzleException;
6
use Psr\Http\Message\ResponseInterface;
7
use VictorAvelar\Phraseapp\PhraseappHttpClient;
8
9
class ProjectsResource extends AbstractPhraseappResource
10
{
11
    /**
12
     * Base resource path.
13
     *
14
     * @var string
15
     */
16
    const RESOURCE_PATH = '/projects';
17
18
    /**
19
     * ProjectsResource constructor.
20
     *
21
     * @param PhraseappHttpClient $client
22
     */
23 6
    public function __construct(PhraseappHttpClient $client)
24
    {
25 6
        parent::__construct($client);
26 6
    }
27
28
    /**
29
     * List all projects the current user has access to.
30
     *
31
     * @return mixed|ResponseInterface
32
     *
33
     * @throws GuzzleException
34
     */
35 3
    public function listProjects()
36
    {
37 3
        $req = $this->buildRequest('GET', self::RESOURCE_PATH);
38
39 3
        return $this->execute($req);
40
    }
41
42
    /**
43
     * Get details on a single project.
44
     *
45
     * @param string $projectId
46
     *
47
     * @return mixed|ResponseInterface
48
     *
49
     * @throws GuzzleException
50
     */
51 3
    public function getProject(string $projectId)
52
    {
53 3
        $req = $this->buildRequest('GET', self::RESOURCE_PATH . "/$projectId");
54
55 3
        return $this->execute($req);
56
    }
57
}
58