Completed
Pull Request — master (#2)
by Pol
07:20 queued 05:24
created

Time   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
cbo 4
dl 0
loc 48
ccs 0
cts 24
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 23 1
A get() 0 4 1
1
<?php
2
3
namespace drupol\Yaroc\Examples;
4
5
use drupol\Yaroc\Plugin\Provider;
6
7
/**
8
 * Class Time.
9
 */
10
class Time extends BaseExample
11
{
12
    /**
13
     * @var integer[]
14
     */
15
    protected $time;
16
17
    /**
18
     * @throws \Http\Client\Exception
19
     *
20
     * @return $this
21
     *
22
     * @SuppressWarnings(PHPMD.StaticAccess)
23
     */
24
    public function find()
25
    {
26
        $provider = Provider::withResource('generateIntegers');
27
28
        $hours = $this->getRandomOrgAPI()->getData(
29
            $provider->withParameters(
30
                ['n' => 1, 'min' => 0, 'max' => 23]
31
            )
32
        );
33
        $minutesSeconds = $this->getRandomOrgAPI()->getData(
34
            $provider->withParameters(
35
                ['n' => 2, 'min' => 0, 'max' => 59]
36
            )
37
        );
38
39
        $this->time = [
40
            'h' => $hours[0],
41
            'm' => $minutesSeconds[0],
42
            's' => $minutesSeconds[1],
43
        ];
44
45
        return $this;
46
    }
47
48
    /**
49
     * Get the time.
50
     *
51
     * @return integer[]
52
     */
53
    public function get()
54
    {
55
        return $this->time;
56
    }
57
}
58