1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Apie\StatusCheckPlugin\ResourceFactories; |
4
|
|
|
|
5
|
|
|
use Apie\Core\Exceptions\BadConfigurationException; |
6
|
|
|
use Apie\Core\Interfaces\ApiResourceFactoryInterface; |
7
|
|
|
use Apie\Core\Interfaces\ApiResourcePersisterInterface; |
8
|
|
|
use Apie\Core\Interfaces\ApiResourceRetrieverInterface; |
9
|
|
|
use Apie\StatusCheckPlugin\DataLayers\StatusCheckRetriever; |
10
|
|
|
|
11
|
|
|
class StatusRetrieverFallbackFactory implements ApiResourceFactoryInterface |
12
|
|
|
{ |
13
|
|
|
private $statusChecks; |
14
|
|
|
|
15
|
|
|
public function __construct(iterable $statusChecks) |
16
|
|
|
{ |
17
|
|
|
$this->statusChecks = $statusChecks; |
18
|
|
|
} |
19
|
|
|
/** |
20
|
|
|
* Returns true if this factory can create this identifier. |
21
|
|
|
* |
22
|
|
|
* @param string $identifier |
23
|
|
|
* @return bool |
24
|
|
|
*/ |
25
|
|
|
public function hasApiResourceRetrieverInstance(string $identifier): bool |
26
|
|
|
{ |
27
|
|
|
return $identifier === StatusCheckRetriever::class; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Gets an instance of ApiResourceRetrieverInstance |
32
|
|
|
* @param string $identifier |
33
|
|
|
* @return ApiResourceRetrieverInterface |
34
|
|
|
*/ |
35
|
|
|
public function getApiResourceRetrieverInstance(string $identifier): ApiResourceRetrieverInterface |
36
|
|
|
{ |
37
|
|
|
return new StatusCheckRetriever($this->statusChecks); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Returns true if this factory can create this identifier. |
42
|
|
|
* |
43
|
|
|
* @param string $identifier |
44
|
|
|
* @return bool |
45
|
|
|
*/ |
46
|
|
|
public function hasApiResourcePersisterInstance(string $identifier): bool |
47
|
|
|
{ |
48
|
|
|
return false; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Gets an instance of ApiResourceRetrieverInstance |
53
|
|
|
* @param string $identifier |
54
|
|
|
* @return ApiResourcePersisterInterface |
55
|
|
|
*/ |
56
|
|
|
public function getApiResourcePersisterInstance(string $identifier): ApiResourcePersisterInterface |
57
|
|
|
{ |
58
|
|
|
throw new BadConfigurationException('This call is not supposed to be called'); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|