Completed
Push — develop ( 93a8b4...80313a )
by Siad
02:18
created

UserContextFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 9 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\Context\UserContext;
22
use Qandidate\Toggle\Context;
23
use Zend\Authentication\AuthenticationServiceInterface;
24
use Zend\ServiceManager\Exception\ServiceNotFoundException;
25
use Zend\ServiceManager\FactoryInterface;
26
use Zend\ServiceManager\ServiceLocatorInterface;
27
28
class UserContextFactory implements FactoryInterface
29
{
30
    /**
31
     * Create service
32
     *
33
     * @param ServiceLocatorInterface $serviceLocator
34
     *
35
     * @return Context
36
     *
37
     * @throws ServiceNotFoundException
38
     */
39 1
    public function createService(ServiceLocatorInterface $serviceLocator)
40
    {
41
        /** @var AuthenticationServiceInterface $storage */
42 1
        $storage = $serviceLocator->get('FeatureToggle\Storage');
43
44 1
        $userContext = new UserContext($storage);
45
46 1
        return $userContext->createContext();
47
    }
48
}
49