-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperatorImplementationsList.php
54 lines (47 loc) · 1.21 KB
/
OperatorImplementationsList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Kora\DataProvider;
/**
* Class DataProviderOperatorImplementations
* @author Paweł Gierlasiński <[email protected]>
*/
class OperatorImplementationsList
{
/**
* @var OperatorImplementationInterface[]
*/
protected $implementations = [];
/**
* @param string $code
* @param OperatorImplementationInterface $implementation
* @return OperatorImplementationsList
*/
public function addImplementation(string $code, OperatorImplementationInterface $implementation): self
{
$this->implementations[$code] = $implementation;
return $this;
}
/**
* @param string $code
* @return bool
*/
public function hasImplementation(string $code): bool
{
return isset($this->implementations[$code]);
}
/**
* @param string $code
* @return OperatorImplementationInterface
*/
public function getImplementation(string $code): OperatorImplementationInterface
{
return $this->implementations[$code];
}
/**
* @param OperatorDefinitionInterface $definition
* @return string
*/
public static function getOperatorCode(OperatorDefinitionInterface $definition): string
{
return get_class($definition);
}
}