Passed
Push — master ( 8242d2...71bfa3 )
by Arnold
05:32
created

MockSession::start()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
declare(strict_types=1);
4
5
namespace Jasny\Session;
6
7
use Jasny\Session\Flash\FlashBag;
8
use Jasny\Session\Flash\FlashTrait;
9
10
/**
11
 * Session that only exists in local memory
12
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
13
class MockSession extends \ArrayObject implements SessionInterface
0 ignored issues
show
introduced by
Class Jasny\Session\MockSession extends generic class ArrayObject but does not specify its types: TKey, TValue
Loading history...
14
{
15
    use FlashTrait;
16
17
    protected array $initialData;
0 ignored issues
show
introduced by
Property Jasny\Session\MockSession::$initialData type has no value type specified in iterable type array.
Loading history...
18
    protected int $status = \PHP_SESSION_ACTIVE;
19
20
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $input should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $flashes should have a doc-comment as per coding-style.
Loading history...
21
     * MockSession constructor.
22
     */
23
    public function __construct(array $input = [], ?FlashBag $flashes = null)
0 ignored issues
show
introduced by
Method Jasny\Session\MockSession::__construct() has parameter $flashes with no value type specified in iterable type Jasny\Session\Flash\FlashBag.
Loading history...
introduced by
Method Jasny\Session\MockSession::__construct() has parameter $input with no value type specified in iterable type array.
Loading history...
24
    {
25
        $this->initialData = $input;
26
        $this->flashes = $flashes ?? new FlashBag();
27
28
        parent::__construct($input);
29
    }
30
31
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
32
     * @inheritDoc
33
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
34
    public function status(): int
35
    {
36
        return $this->status;
37
    }
38
39
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
40
     * @inheritDoc
41
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
42
    public function start(): void
43
    {
44
        $this->status = \PHP_SESSION_ACTIVE;
45
    }
46
47
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
48
     * @inheritDoc
49
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
50
    public function stop(): void
51
    {
52
        $this->initialData = $this->getArrayCopy();
53
        $this->status = \PHP_SESSION_NONE;
54
    }
55
56
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
57
     * @inheritDoc
58
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
59
    public function abort(): void
60
    {
61
        $this->exchangeArray($this->initialData);
62
        $this->status = \PHP_SESSION_NONE;
63
    }
64
65
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
66
     * @inheritDoc
67
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
68
    public function clear(): void
69
    {
70
        $this->exchangeArray([]);
71
    }
72
}
73