Passed
Push — master ( 8bdcbb...696730 )
by Zbigniew
03:20
created

Api::getIdResource()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the zibios/wrike-php-library package.
5
 *
6
 * (c) Zbigniew Ślązak
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zibios\WrikePhpLibrary;
13
14
use Zibios\WrikePhpLibrary\Transformer\ApiExceptionTransformerInterface;
15
use Zibios\WrikePhpLibrary\Transformer\ResponseTransformerInterface;
16
use Zibios\WrikePhpLibrary\Validator\AccessTokenValidator;
17
18
/**
19
 * General Wrike Api.
20
 *
21
 * Entry point for all Wrike API operations. Immutable.
22
 *
23
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24
 * @SuppressWarnings(PHPMD.TooManyFields)
25
 */
26
class Api extends AbstractApi implements ImmutableApiInterface
27
{
28
    /**
29
     * @param string $accessToken
30
     *
31
     * @throws \InvalidArgumentException
32
     *
33
     * @return $this
34
     */
35 1
    public function recreateForNewAccessToken($accessToken)
36
    {
37 1
        AccessTokenValidator::assertIsValid($accessToken);
38
39 1
        return new self($this->client, $this->responseTransformer, $this->apiExceptionTransformer, $accessToken);
40
    }
41
42
    /**
43
     * @param ApiExceptionTransformerInterface $apiExceptionTransformer
44
     *
45
     * @throws \InvalidArgumentException
46
     *
47
     * @return $this
48
     */
49 1
    public function recreateForNewApiExceptionTransformer(ApiExceptionTransformerInterface $apiExceptionTransformer)
50
    {
51 1
        return new self($this->client, $this->responseTransformer, $apiExceptionTransformer, $this->accessToken);
52
    }
53
54
    /**
55
     * @param ResponseTransformerInterface $responseTransformer
56
     *
57
     * @throws \InvalidArgumentException
58
     *
59
     * @return $this
60
     */
61 1
    public function recreateForNewResponseTransformer(ResponseTransformerInterface $responseTransformer)
62
    {
63 1
        return new self($this->client, $responseTransformer, $this->apiExceptionTransformer, $this->accessToken);
64
    }
65
}
66