Test Failed
Pull Request — master (#2)
by Pol
03:30
created

Coin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
cbo 3
dl 0
loc 36
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\Method\GenerateIntegers;
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
    public function flip()
23
    {
24
        $parameters = ['n' => 1, 'min' => 0, 'max' => 1];
25
26
        $generateIntegers = (new GenerateIntegers($this->getHttpClient()))
27
            ->withParameters($parameters);
28
29
        $result = $this->getRandomOrgAPI()->getData($generateIntegers);
30
31
        $this->face = (1 == $result[0]) ? 'tails' : 'heads';
32
33
        return $this;
34
    }
35
36
    /**
37
     * Get the coin face.
38
     *
39
     * @return string
40
     */
41
    public function getFace()
42
    {
43
        return $this->face;
44
    }
45
}
46