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

Frame::isComplete()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5.0488

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 7
cts 8
cp 0.875
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 4
nop 0
crap 5.0488
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