Api::recreateForNewAccessToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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;
15
16
use Zibios\WrikePhpLibrary\Transformer\ApiExceptionTransformerInterface;
17
use Zibios\WrikePhpLibrary\Transformer\ResponseTransformerInterface;
18
use Zibios\WrikePhpLibrary\Validator\AccessTokenValidator;
19
20
/**
21
 * General Wrike Api.
22
 *
23
 * Entry point for all Wrike API operations. Immutable.
24
 *
25
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26
 * @SuppressWarnings(PHPMD.TooManyFields)
27
 */
28
class Api extends AbstractApi implements ImmutableApiInterface
29
{
30
    /**
31
     * @param string $accessToken
32
     *
33
     * @throws \InvalidArgumentException
34
     *
35
     * @return $this
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
36
     */
37 1
    public function recreateForNewAccessToken($accessToken): self
38
    {
39 1
        AccessTokenValidator::assertIsValid($accessToken);
40
41 1
        return new self($this->client, $this->responseTransformer, $this->apiExceptionTransformer, $accessToken);
42
    }
43
44
    /**
45
     * @param ApiExceptionTransformerInterface $apiExceptionTransformer
46
     *
47
     * @throws \InvalidArgumentException
48
     *
49
     * @return $this
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
50
     */
51 1
    public function recreateForNewApiExceptionTransformer(ApiExceptionTransformerInterface $apiExceptionTransformer): self
52
    {
53 1
        return new self($this->client, $this->responseTransformer, $apiExceptionTransformer, $this->accessToken);
54
    }
55
56
    /**
57
     * @param ResponseTransformerInterface $responseTransformer
58
     *
59
     * @throws \InvalidArgumentException
60
     *
61
     * @return $this
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
62
     */
63 1
    public function recreateForNewResponseTransformer(ResponseTransformerInterface $responseTransformer): self
64
    {
65 1
        return new self($this->client, $responseTransformer, $this->apiExceptionTransformer, $this->accessToken);
66
    }
67
}
68