ProjectsResource::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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