Completed
Push — Bowlingkata/Albert ( a8d0e2...ff2053 )
by Albert
02:01
created

RollType   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 48
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromMark() 0 14 4
A isEmpty() 0 4 1
A isDefault() 0 4 1
A isSpare() 0 4 1
A isStrike() 0 4 1
1
<?php
2
3
namespace Kata\BowlingKata\Domain;
4
5
final class RollType
6
{
7
    const EMPTY = '-';
8
    const SPARE = '/';
9
    const STRIKE = 'X';
10
11
    private $type;
12
13 38
    private function __construct($a_type)
14
    {
15 38
        $this->type = $a_type;
16 38
    }
17
18 38
    public static function fromMark($a_mark) : self
19
    {
20 38
        if (self::EMPTY == $a_mark) {
21 31
            return new self('empty');
22
        }
23 37
        if (self::SPARE == $a_mark) {
24 13
            return new self('spare');
25
        }
26 36
        if (self::STRIKE == $a_mark) {
27 15
            return new self('strike');
28
        }
29
30 29
        return new self('default');
31
    }
32
33 35
    public function isEmpty() : bool
34
    {
35 35
        return 'empty' == $this->type;
36
    }
37
38 35
    public function isDefault() : bool
39
    {
40 35
        return 'default' == $this->type;
41
    }
42
43 35
    public function isSpare() : bool
44
    {
45 35
        return 'spare' == $this->type;
46
    }
47
48 35
    public function isStrike() : bool
49
    {
50 35
        return 'strike' == $this->type;
51
    }
52
}
53