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

Coin::flip()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
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