1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://github.com/flipbox/relay-hubspot/blob/master/LICENSE |
6
|
|
|
* @link https://github.com/flipbox/relay-hubspot |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Flipbox\Relay\HubSpot\Builder\Resources\Blog\Posts; |
10
|
|
|
|
11
|
|
|
use Flipbox\Relay\HubSpot\AuthorizationInterface; |
12
|
|
|
use Flipbox\Relay\HubSpot\Builder\HttpRelayBuilder; |
13
|
|
|
use Flipbox\Relay\HubSpot\Middleware\JsonRequest as JsonMiddleware; |
14
|
|
|
use Flipbox\Relay\HubSpot\Middleware\ResourceV2; |
15
|
|
|
use Flipbox\Relay\Middleware\SimpleCache as CacheMiddleware; |
16
|
|
|
use Psr\Log\LoggerInterface; |
17
|
|
|
use Psr\SimpleCache\CacheInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Flipbox Factory <[email protected]> |
21
|
|
|
* @since 1.3.0 |
22
|
|
|
*/ |
23
|
|
|
class All extends HttpRelayBuilder |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* The node |
27
|
|
|
*/ |
28
|
|
|
const NODE = 'content/api'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The resource |
32
|
|
|
*/ |
33
|
|
|
const RESOURCE = 'blog-posts'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param array $params |
37
|
|
|
* @param CacheInterface $cache |
38
|
|
|
* @param AuthorizationInterface $authorization |
39
|
|
|
* @param LoggerInterface|null $logger |
40
|
|
|
* @param array $config |
41
|
|
|
*/ |
42
|
|
|
public function __construct( |
43
|
|
|
array $params, |
44
|
|
|
AuthorizationInterface $authorization, |
45
|
|
|
CacheInterface $cache, |
46
|
|
|
LoggerInterface $logger = null, |
47
|
|
|
$config = [] |
48
|
|
|
) { |
49
|
|
|
parent::__construct($authorization, $logger, $config); |
50
|
|
|
|
51
|
|
|
$cacheKey = self::RESOURCE . md5(serialize($params)); |
52
|
|
|
|
53
|
|
|
$this->addUri($params, $logger) |
54
|
|
|
->addCache($cache, $cacheKey, $logger); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param CacheInterface $cache |
59
|
|
|
* @param string $key |
60
|
|
|
* @param LoggerInterface|null $logger |
61
|
|
|
* @return $this |
62
|
|
|
*/ |
63
|
|
|
protected function addCache(CacheInterface $cache, string $key, LoggerInterface $logger = null) |
64
|
|
|
{ |
65
|
|
|
return $this->addAfter('cache', [ |
66
|
|
|
'class' => CacheMiddleware::class, |
67
|
|
|
'logger' => $logger ?: $this->getLogger(), |
68
|
|
|
'cache' => $cache, |
69
|
|
|
'key' => $key |
70
|
|
|
], 'body'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $domain |
|
|
|
|
75
|
|
|
* @param LoggerInterface|null $logger |
76
|
|
|
* @return $this |
77
|
|
|
*/ |
78
|
|
|
protected function addUri(array $params, LoggerInterface $logger = null) |
79
|
|
|
{ |
80
|
|
|
return $this->addBefore('uri', [ |
81
|
|
|
'class' => ResourceV2::class, |
82
|
|
|
'method' => 'GET', |
83
|
|
|
'params' => $params, |
84
|
|
|
'node' => self::NODE, |
85
|
|
|
'resource' => self::RESOURCE, |
86
|
|
|
'logger' => $logger ?: $this->getLogger() |
87
|
|
|
]); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.