Completed
Pull Request — master (#2)
by Pol
07:20 queued 05:24
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
     * @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