Completed
Push — master ( 3718bf...59e23c )
by Pol
02:36
created

Time::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
3
namespace drupol\Yaroc\Examples;
4
5
/**
6
 * Class Time.
7
 *
8
 * @package drupol\Yaroc\Examples
9
 */
10
class Time extends BaseExample {
11
12
  /**
13
   * @var int[]
14
   */
15
  protected $time;
16
17
  /**
18
   * Find random time.
19
   *
20
   * @return self
21
   */
22 1
  public function find() {
0 ignored issues
show
Coding Style Naming introduced by Pol Dellaiera
The variable $minutes_seconds is not named in camelCase.

This check marks variable names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
23 1
    $hours = $this->randomOrgAPI->call('generateIntegers', ['n' => 1, 'min' => 0, 'max' => 23])->getData();
24 1
    $minutes_seconds = $this->randomOrgAPI->call('generateIntegers', ['n' => 2, 'min' => 0, 'max' => 59])->getData();
25
26 1
    $this->time = [
0 ignored issues
show
Documentation Bug introduced by Pol Dellaiera
It seems like array('h' => $hours[0], ...=> $minutes_seconds[1]) of type array<string,?,{"h":"?","m":"?","s":"?"}> is incompatible with the declared type array<integer,integer> of property $time.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
27 1
      'h' => $hours[0],
28 1
      'm' => $minutes_seconds[0],
29 1
      's' => $minutes_seconds[1],
30
    ];
31
32 1
    return $this;
33
  }
34
35
  /**
36
   * Get the time.
37
   *
38
   * @return string
0 ignored issues
show
Documentation introduced by Pol Dellaiera
Should the return type not be integer[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
39
   */
40 1
  public function get() {
41 1
    return $this->time;
42
  }
43
44
}
45