Completed
Push — master ( 69f82d...a3a3e6 )
by Pol
13:34 queued 11:03
created

Coin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
cbo 2
dl 0
loc 31
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A flip() 0 8 2
A getFace() 0 3 1
1
<?php
2
3
namespace drupol\Yaroc\Examples;
4
5
/**
6
 * Class Coin.
7
 *
8
 * @package drupol\Yaroc\Examples
9
 */
10
class Coin extends BaseExample {
11
12
  /**
13
   * @var string
14
   */
15
  protected $face;
16
17
  /**
18
   * Flip the coin.
19
   *
20
   * @return self
21
   */
22 1
  public function flip() {
23 1
    $result = $this->randomOrgAPI->call('generateIntegers', ['n' => 1, 'min' => 0, 'max' => 1])
24 1
      ->getResult();
25
26 1
    $this->face = (1 == $result['random']['data'][0]) ? 'tails' : 'heads';
27
28 1
    return $this;
29
  }
30
31
  /**
32
   * Get the coin face.
33
   *
34
   * @return string
35
   */
36 1
  public function getFace() {
37 1
    return $this->face;
38
  }
39
40
}
41