MemPersistenceAdapter::getLast()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace cwreden\php7ccAnalyser;
4
5
6
class MemPersistenceAdapter implements PersistenceAdapterInterface
7
{
8
    /**
9
     * @var Scan
10
     */
11
    private $lastScan = null;
12
13
    /**
14
     * @param Scan $scan
15
     */
16 2
    public function persist(Scan $scan): void
17
    {
18 2
        $this->lastScan = $scan;
19 2
    }
20
21
    /**
22
     * @return Scan
23
     * @throws NoPreviousScanFoundException
24
     */
25 3
    public function getLast(): Scan
26
    {
27 3
        if ($this->lastScan === null) {
28 1
            throw new NoPreviousScanFoundException();
29
        }
30 2
        return $this->lastScan;
31
    }
32
}