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

Api   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 40
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A recreateForNewAccessToken() 0 6 1
A recreateForNewApiExceptionTransformer() 0 4 1
A recreateForNewResponseTransformer() 0 4 1
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