Sleeper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A speed() 0 8 3
A sleep() 0 4 1
1
<?php
2
3
namespace League\CLImate\TerminalObject\Helper;
4
5
class Sleeper implements SleeperInterface
6
{
7
    /**
8
     * The default length of the sleep
9
     *
10
     * @var int|float $speed
11
     */
12
    protected $speed = 50000;
13
14
    /**
15
     * Set the speed based on a percentage (50% slower, 200% faster, etc)
16
     *
17
     * @param int|float $percentage
18
     *
19
     * @return float
20
     */
21 12
    public function speed($percentage)
22
    {
23 12
        if (is_numeric($percentage) && $percentage > 0) {
24 8
            $this->speed *= (100 / $percentage);
25 8
        }
26
27 12
        return $this->speed;
28
    }
29
30
    /**
31
     * Sleep for the specified amount of time
32
     */
33 12
    public function sleep()
34
    {
35 12
        usleep($this->speed);
36 12
    }
37
}
38