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

Time   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 12 1
A get() 0 3 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
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
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
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