Completed
Push — prototype ( e00165...767fff )
by Peter
07:53
created

RouteConstructorTrait::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Webino™ (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoConfigLib\Router\Route\Regex;
12
13
use WebinoConfigLib\Router\RouteInterface;
14
15
/**
16
 * Trait RouteConstructorTrait
17
 */
18
trait RouteConstructorTrait
19
{
20
    /**
21
     * @var string
22
     */
23
    private $path;
24
25
    /**
26
     * @var string
27
     */
28
    private $spec;
29
30
    /**
31
     * {@inheritdoc}
32
     * @see \WebinoConfigLib\Router\Route\Regex\RouteConstructorInterface
33
     */
34
    public function __construct($path, $spec = null)
35
    {
36
        $this
37
            ->setPath($path)
38
            ->setSpec($spec)
39
            ->setType(RouteInterface::REGEX)
40
            ->init();
41
    }
42
43
    /**
44
     * @param string $path
45
     * @return $this
46
     */
47
    abstract protected function setPath($path);
48
49
    /**
50
     * @param string|null $spec
51
     * @return $this
52
     */
53
    abstract protected function setSpec($spec = null);
54
55
    /**
56
     * @param string $type Route type.
57
     * @return $this
58
     */
59
    abstract public function setType($type = RouteInterface::LITERAL);
60
61
    /**
62
     * Initialize route
63
     *
64
     * @return void
65
     */
66
    abstract protected function init();
67
}
68