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 |
|
|
|
|
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 |
|
|
|
|
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 |
|
|
|
|
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
|
|
|
|
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.