FlashRedirect::createSimple()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 4
crap 1
1
<?php
2
3
namespace Zenstruck\ControllerUtil;
4
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
class FlashRedirect extends Redirect implements HasFlashes
9
{
10
    private $flashes;
11
12
    /**
13
     * @param string $route
14
     * @param array  $parameters
15
     * @param string $message
16
     * @param string $type
17
     * @param int    $statusCode
18
     *
19
     * @return static
20
     */
21 1
    public static function create($route, array $parameters, $message, $type = self::DEFAULT_FLASH_KEY, $statusCode = self::DEFAULT_STATUS_CODE)
22
    {
23 1
        return new static($route, $parameters, array($type => array($message)), $statusCode);
24
    }
25
26
    /**
27
     * @param string $route
28
     * @param string $message
29
     * @param string $type
30
     * @param int    $statusCode
31
     *
32
     * @return static
33
     */
34 2
    public static function createSimple($route, $message, $type = self::DEFAULT_FLASH_KEY, $statusCode = self::DEFAULT_STATUS_CODE)
35
    {
36 2
        return new static($route, array(), array($type => array($message)), $statusCode);
37
    }
38
39
    /**
40
     * @param string $route
41
     * @param array  $parameters
42
     * @param array  $flashes
43
     * @param int    $statusCode
44
     */
45 3
    public function __construct($route, array $parameters = array(), array $flashes = array(), $statusCode = self::DEFAULT_STATUS_CODE)
46
    {
47 3
        $this->flashes = $flashes;
48
49 3
        parent::__construct($route, $parameters, $statusCode);
50 3
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 3
    public function getFlashes()
56
    {
57 3
        return $this->flashes;
58
    }
59
}
60