Completed
Push — GildedRose/AlbertAndMarcos ( c4eed1 )
by Albert
02:33
created

BackstagePassItem::concertDateIsClose()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Kata\GildedRoseKata;
3
4
final class BackstagePassItem extends BaseItem
5
{
6
    const ITEM_NAME = 'Backstage passes to a TAFKAL80ETC concert';
7
    const DEGRADE_WITH_TIME = false;
8
9
    const DAYS_TO_BE_VERY_CLOSE = 5;
10
    const DAYS_TO_BE_CLOSE = 10;
11
12 5
    protected function getQualityMagnitudeForNextUpdate()
13
    {
14 5
        if ($this->concertHasStartedOrHasBeenCelebrated()) {
15 1
            return -$this->item->quality;
16
        }
17 5
        if ($this->concertDateIsVeryClose()) {
18 3
            return 3;
19
        }
20 2
        if ($this->concertDateIsClose()) {
21 1
            return 2;
22
        }
23
24 1
        return 1;
25
    }
26
27 5
    private function concertHasStartedOrHasBeenCelebrated()
28
    {
29 5
        return $this->item->sell_in <= 0;
30
    }
31
32 5
    private function concertDateIsVeryClose()
33
    {
34 5
        return $this->item->sell_in <= self::DAYS_TO_BE_VERY_CLOSE;
35
    }
36
37 2
    private function concertDateIsClose()
38
    {
39 2
        return $this->item->sell_in <= self::DAYS_TO_BE_CLOSE;
40
    }
41
}
42