Warp::getMeasuresOfTime()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Monolol\Lolifiers;
4
5
use Monolol\Lolifier;
6
7
class Warp implements Lolifier
8
{
9
    const
10
        MIN_INTERVAL = 1,
11
        MAX_INTERVAL = 5;
12
        
13 1
    public function isHandling(array $record)
14
    {
15 1
        return true;
16
    }
17
    
18 1
    public function lolify(array $record)
19
    {
20 1
        $this->travelIntoWarp($record['datetime']);
21
        
22 1
        return $record;
23
    }
24
    
25 1
    private function travelIntoWarp(\DateTime $datetime)
26
    {
27 1
        foreach($this->getMeasuresOfTime() as $measure => $prefix)
28
        {
29 1
            $interval = rand(self::MIN_INTERVAL, self::MAX_INTERVAL);
30
            
31 1
            $datetime->add(new \DateInterval($prefix . $interval . $measure));
32 1
        }
33 1
    }
34
    
35 1
    private function getMeasuresOfTime()
36
    {
37
        return array(
38 1
            'S' => 'PT',
39 1
            'M' => 'PT',
40 1
            'H' => 'PT',
41 1
            'D' => 'P',
42 1
            'M' => 'P',
43 1
        );
44
    }
45
}
46