Completed
Push — develop ( 22a4dc...135c40 )
by Siad
10:13 queued 07:57
created

FeatureToggleControllerPluginFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
ccs 0
cts 10
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 12 1
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 MehrAlsNix\FeatureToggle\Mvc\Controller\Plugin\FeatureToggle;
22
use Zend\ServiceManager\Exception\ServiceNotFoundException;
23
use Zend\ServiceManager\FactoryInterface;
24
use Zend\ServiceManager\ServiceLocatorInterface;
25
26
class FeatureToggleControllerPluginFactory implements FactoryInterface
27
{
28
    /**
29
     * Create service
30
     *
31
     * @param ServiceLocatorInterface $serviceLocator
32
     *
33
     * @return FeatureToggle
34
     *
35
     * @throws ServiceNotFoundException
36
     */
37
    public function createService(ServiceLocatorInterface $serviceLocator)
38
    {
39
        $serviceLocator = $serviceLocator->getServiceLocator();
40
        $toggleManager = $serviceLocator->get('ToggleManagerFactory');
41
        $toggleContext = $serviceLocator->get('ToggleContextFactory');
42
43
        $plugin = new FeatureToggle();
44
        $plugin->setToggleManager($toggleManager);
45
        $plugin->setContext($toggleContext);
46
47
        return $plugin;
48
    }
49
}
50