1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* zf2-featureflags. |
4
|
|
|
* |
5
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
6
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
7
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
8
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
9
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
10
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
11
|
|
|
* SOFTWARE. |
12
|
|
|
* |
13
|
|
|
* @copyright 2016 MehrAlsNix (http://www.mehralsnix.de) |
14
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
15
|
|
|
* |
16
|
|
|
* @link http://github.com/MehrAlsNix/zf2-featureflags |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace MehrAlsNix\FeatureToggle\Factory; |
20
|
|
|
|
21
|
|
|
use Interop\Container\ContainerInterface; |
22
|
|
|
use Qandidate\Toggle\ToggleCollection; |
23
|
|
|
use Qandidate\Toggle\ToggleManager; |
24
|
|
|
use Zend\ServiceManager\Exception\ServiceNotFoundException; |
25
|
|
|
use Zend\ServiceManager\Factory\FactoryInterface; |
26
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
27
|
|
|
|
28
|
|
|
class ToggleManagerFactory implements FactoryInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Create service |
32
|
|
|
* |
33
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
|
|
|
|
34
|
|
|
* |
35
|
|
|
* @return ToggleManager |
36
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
37
|
|
|
*/ |
38
|
2 |
|
public function __invoke(ContainerInterface $container, $requestedName = '', array $options = null) |
39
|
|
|
{ |
40
|
2 |
|
$coll = $container->get( |
41
|
2 |
|
'ToggleFeature\InMemoryCollSerializer' |
42
|
2 |
|
)->deserialize( |
43
|
2 |
|
$container->get('config')['zf2_featureflags']['features'] |
44
|
|
|
); |
45
|
|
|
|
46
|
2 |
|
if (!$coll instanceof ToggleCollection) { |
47
|
1 |
|
throw new ServiceNotFoundException( |
48
|
1 |
|
'Service received is not of type ToggleCollection' |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
return new ToggleManager($coll); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
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.