Completed
Push — develop ( d50dd5...c1b71b )
by Siad
11:12
created

ToggleContextFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
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\Context;
23
use Zend\Config\Config;
24
use Zend\ServiceManager\FactoryInterface;
25
use Zend\ServiceManager\ServiceLocatorInterface;
26
27
class ToggleContextFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
{
29
    /**
30
     * Create an object
31
     *
32
     * @param  ContainerInterface $container
33
     * @param  string $requestedName
34
     * @param  null|array $options
35
     *
36
     * @return Context
37
     *
38
     * @throws \Psr\Container\ContainerExceptionInterface
39
     */
40 1
    public function __invoke(ContainerInterface $container, $requestedName = '', array $options = null)
41
    {
42 1
        $factory = (new Config($container->get('config')))['zf2_featureflags']['qandidate_toggle']['context_factory'];
43
44 1
        $context = new Context();
45
46 1
        if ($factory !== null && $container->has($factory)) {
47
            /** @var Context $context */
48
            $context = $container->get($factory);
49
        }
50
51 1
        return $context;
52
    }
53
54
    /**
55
     * Create service
56
     *
57
     * @param ServiceLocatorInterface $serviceLocator
58
     * @return mixed
59
     */
60
    public function createService(ServiceLocatorInterface $serviceLocator)
61
    {
62
        return $this($serviceLocator);
63
    }
64
}
65