Completed
Push — master ( 60b2be...f29513 )
by Pol
06:10
created

RandomOrg::getPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 3
Ratio 100 %

Importance

Changes 0
Metric Value
dl 3
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace drupol\Yaroc\Plugin\RychRandom\Generator;
4
5
use drupol\Yaroc\RandomOrgAPI;
6
use Rych\Random\Generator\GeneratorInterface;
7
8
/**
9
 * The Random.Org Generator.
10
 *
11
 * @codeCoverageIgnore
12
 */
13 View Code Duplication
class RandomOrg implements GeneratorInterface {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
15
  /**
16
   * The Random.Org API.
17
   *
18
   * @var RandomOrgAPI
19
   */
20
  protected $randomOrgAPI;
21
22
  /**
23
   * RandomOrg constructor.
24
   */
25
  public function __construct() {
26
    $this->randomOrgAPI = new RandomOrgAPI();
27
    $this->randomOrgAPI->setApiKey(file_get_contents('./apikey'));
28
  }
29
30
  /**
31
   * {@inheritdoc}
32
   */
33
  public static function getPriority() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
34
    return GeneratorInterface::PRIORITY_HIGH;
35
  }
36
37
  /**
38
   * {@inheritdoc}
39
   */
40
  public static function isSupported() {
41
    return class_exists('RandomOrgAPI');
42
  }
43
44
  /**
45
   * {@inheritdoc}
46
   */
47
  public function generate($size) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
48
    $result = $this->randomOrgAPI->call('generateStrings', ['n' => 1, 'length' => $size])
49
      ->getResult();
50
51
    return $result['random']['data'][0];
52
  }
53
54
}
55