Warp   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 0
cbo 0
dl 0
loc 39
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isHandling() 0 4 1
A lolify() 0 6 1
A travelIntoWarp() 0 9 2
A getMeasuresOfTime() 0 10 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