We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 17 | abstract class AbstractResolver implements ResolverInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | private $solutions = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var array |
||
| 26 | */ |
||
| 27 | private $solutionOptions = []; |
||
| 28 | |||
| 29 | /** |
||
| 30 | 25 | * @var CacheInterface |
|
| 31 | */ |
||
| 32 | 25 | protected $cache; |
|
| 33 | 25 | ||
| 34 | 25 | public function __construct(CacheInterface $cache = null) |
|
| 35 | { |
||
| 36 | $this->cache = null !== $cache ? $cache : new ArrayCache(); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function addSolution($name, $solution, $options = []) |
||
| 40 | { |
||
| 41 | if (!$this->supportsSolution($solution)) { |
||
| 42 | throw new UnsupportedResolverException( |
||
| 43 | sprintf('Resolver "%s" must be "%s" "%s" given.', $name, $this->supportedSolutionClass(), get_class($solution)) |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->solutions[$name] = $solution; |
||
| 48 | $this->solutionOptions[$name] = $options; |
||
| 49 | |||
| 50 | return $this; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return array |
||
| 55 | */ |
||
| 56 | public function getSolutions() |
||
| 57 | { |
||
| 58 | return $this->solutions; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param $name |
||
| 63 | * |
||
| 64 | * @return mixed |
||
| 65 | */ |
||
| 66 | public function getSolution($name) |
||
| 67 | { |
||
| 68 | return isset($this->solutions[$name]) ? $this->solutions[$name] : null; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param $name |
||
| 73 | * |
||
| 74 | * @return mixed |
||
| 75 | */ |
||
| 76 | public function getSolutionOptions($name) |
||
| 77 | { |
||
| 78 | return isset($this->solutionOptions[$name]) ? $this->solutionOptions[$name] : []; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param $input |
||
| 83 | * |
||
| 84 | * @return mixed |
||
| 85 | */ |
||
| 86 | abstract public function resolve($input); |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param mixed $solution |
||
| 90 | * |
||
| 91 | * @return bool |
||
| 92 | */ |
||
| 93 | protected function supportsSolution($solution) |
||
| 99 | |||
| 100 | /** |
||
| 101 | * default return null to accept mixed type. |
||
| 102 | * |
||
| 103 | * @return null|string supported class name |
||
| 104 | */ |
||
| 105 | protected function supportedSolutionClass() |
||
| 109 | } |
||
| 110 |