Completed
Pull Request — master (#2)
by Pol
02:05
created

Time::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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
    public function find()
23
    {
24
        $provider = Provider::withResource('generateIntegers');
25
26
        $hours = $this->getRandomOrgAPI()->getData(
27
            $provider->withParameters(
28
                ['n' => 1, 'min' => 0, 'max' => 23]
29
            )
30
        );
31
        $minutesSeconds = $this->getRandomOrgAPI()->getData(
32
            $provider->withParameters(
33
                ['n' => 2, 'min' => 0, 'max' => 59]
34
            )
35
        );
36
37
        $this->time = [
38
            'h' => $hours[0],
39
            'm' => $minutesSeconds[0],
40
            's' => $minutesSeconds[1],
41
        ];
42
43
        return $this;
44
    }
45
46
    /**
47
     * Get the time.
48
     *
49
     * @return integer[]
50
     */
51
    public function get()
52
    {
53
        return $this->time;
54
    }
55
}
56