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

Frame   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 30
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addRoll() 0 4 1
B isComplete() 0 16 5
1
<?php
2
3
namespace Kata\BowlingKata\Domain;
4
5
final class Frame
6
{
7
    const MAX_FRAME_SCORE = 10;
8
    const MAX_ROLLS_BY_FRAME = 2;
9
10
    /** @var Roll[] */
11
    private $roll_array;
12
13 34
    public function addRoll(Roll $a_roll)
14
    {
15 34
        $this->roll_array[] = $a_roll;
16 34
    }
17
18 34
    public function isComplete() : bool
19
    {
20 34
        if (empty($this->roll_array)) {
21
            return false;
22
        }
23
24 34
        if (self::MAX_ROLLS_BY_FRAME == count($this->roll_array)) {
25 32
            return true;
26
        }
27
28 34
        if ($this->roll_array[0]->type()->isSpare() || $this->roll_array[0]->type()->isStrike()) {
29 14
            return true;
30
        }
31
32 32
        return false;
33
    }
34
}
35