Completed
Push — master ( c0f250...321e24 )
by Filipe
15:10
created

ContextCreator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of slick/web_stack package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\WebStack\Controller;
11
12
use Aura\Router\Route;
13
use Psr\Http\Message\ServerRequestInterface;
14
use Slick\WebStack\Service\UriGeneratorInterface;
15
16
/**
17
 * Context Creator
18
 *
19
 * @package Slick\WebStack\Controller
20
 */
21
class ContextCreator
22
{
23
    /**
24
     * @var UriGeneratorInterface
25
     */
26
    private $uriGenerator;
27
28
    /**
29
     * Creates a ContextCreator
30
     *
31
     * @param UriGeneratorInterface $uriGenerator
32
     */
33
    public function __construct(UriGeneratorInterface $uriGenerator)
34
    {
35
        $this->uriGenerator = $uriGenerator;
36
    }
37
38
    /**
39
     * Creates a container context for provided request and route
40
     *
41
     * @param ServerRequestInterface $request
42
     * @param Route                  $route
43
     *
44
     * @return ControllerContextInterface
45
     */
46
    public function create(ServerRequestInterface $request, Route $route)
47
    {
48
        $this->uriGenerator->setRequest($request);
49
        return new Context($request, $route, $this->uriGenerator);
50
    }
51
}
52