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

Coin::getFace()   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 2
Bugs 0 Features 0
Metric Value
c 2
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 Coin.
9
 */
10
class Coin extends BaseExample
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $face;
16
17
    /**
18
     * @throws \Http\Client\Exception
19
     *
20
     * @return $this
21
     *
22
     * @SuppressWarnings(PHPMD.StaticAccess)
23
     */
24
    public function flip()
25
    {
26
        $parameters = ['n' => 1, 'min' => 0, 'max' => 1];
27
28
        $generateIntegers = Provider::withResource('generateIntegers')
29
            ->withParameters($parameters);
30
31
        $result = $this->getRandomOrgAPI()->getData($generateIntegers);
32
33
        $this->face = (1 === $result[0]) ? 'tails' : 'heads';
34
35
        return $this;
36
    }
37
38
    /**
39
     * Get the coin face.
40
     *
41
     * @return string
42
     */
43
    public function getFace()
44
    {
45
        return $this->face;
46
    }
47
}
48