1 | <?php |
||
18 | class ComposerPluginManager extends AbstractPluginManager |
||
19 | { |
||
20 | protected $instanceOf = PluginInterface::class; |
||
21 | |||
22 | /** |
||
23 | * Validate the plugin is of the expected type (v3). |
||
24 | * |
||
25 | * Validates against `$instanceOf`. |
||
26 | * |
||
27 | * @param mixed $instance |
||
28 | * @throws InvalidServiceException |
||
29 | */ |
||
30 | 16 | public function validate($instance) |
|
31 | { |
||
32 | 16 | if (! $instance instanceof $this->instanceOf) { |
|
33 | 3 | throw new InvalidServiceException(sprintf( |
|
34 | 3 | '%s can only create instances of %s; %s is invalid', |
|
35 | 3 | get_class($this), |
|
36 | 3 | $this->instanceOf, |
|
37 | 3 | (is_object($instance) ? get_class($instance) : gettype($instance)) |
|
38 | )); |
||
39 | } |
||
40 | 13 | } |
|
41 | |||
42 | /** |
||
43 | * Validate the plugin is of the expected type (v2). |
||
44 | * |
||
45 | * Proxies to `validate()`. |
||
46 | * |
||
47 | * @param mixed $instance |
||
48 | * @throws RuntimeException |
||
49 | */ |
||
50 | 2 | public function validatePlugin($instance) |
|
58 | |||
59 | /** |
||
60 | * Canonicalize name |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @return string |
||
64 | */ |
||
65 | protected function canonicalizeName($name) |
||
69 | } |
||
70 |