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

Coin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
cbo 4
dl 0
loc 38
ccs 0
cts 13
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A flip() 0 13 2
A getFace() 0 4 1
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