Departures::getCurrentTime()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * User: ms
4
 * Date: 29.08.15
5
 * Time: 09:36
6
 */
7
8
namespace  Mvg\Parser\Html;
9
10
11
use phpQuery;
12
use Mvg\Parser\AbstractParser;
13
/**
14
 * Class Departures
15
 * @package Mvg\Parser\Html
16
 */
17
class Departures extends AbstractParser {
18
19
	/**
20
	 * @var string
21
	 */
22
	protected $currentTime;
23
24
	/**
25
	 * @var string
26
	 */
27
	protected $station;
28
29
	/**
30
	 * @var array
31
	 */
32
	protected $departureObjects = array();
33
34
	/**
35
	 * @param $htmlResponse
36
	 */
37
	public function __construct($htmlResponse) {
38
39
		parent::__construct($htmlResponse);
40
41
		$html = $this->getHtmlResponse();
42
		phpQuery::newDocumentHTML($html);
0 ignored issues
show
Documentation introduced by
$html is of type string, but the function expects a object<unknown_type>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
		$tableRows = pq('.rowEven,.rowOdd');
44
		foreach ($tableRows as $tableRow) {
45
			$tableRow = pq($tableRow)->remove('.spacer');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 21 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
46
			$departureObject = new \stdClass();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
47
			$departureObject->lineNumber = trim(pq($tableRow)->find('.lineColumn')->html());
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
48
			$departureObject->destination = trim(preg_replace("(<([a-z]+).*?>.*?</\\1>)is", "", pq($tableRow)->find('.stationColumn')->html()));
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
49
			$departureObject->time = trim(pq($tableRow)->find('.inMinColumn')->html());
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
50
			$this->departureObjects[] = $departureObject;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
51
52
		}
53
54
		//Time + Station name
55
		$this->setStation(pq('.headerStationColumn')->html());
56
		$this->setCurrentTime(pq('.serverTimeColumn')->html());
57
58
59
	}
60
61
	public function getDepartures() {
62
		return $this->departureObjects;
63
	}
64
65
	/**
66
	 * @return string
67
	 */
68
	public function getCurrentTime() {
69
		return $this->currentTime;
70
	}
71
72
	/**
73
	 * @param string $currentTime
74
	 */
75
	protected function setCurrentTime($currentTime) {
76
		$this->currentTime = $currentTime;
77
	}
78
79
	/**
80
	 * @return string
81
	 */
82
	public function getStation() {
83
		return $this->station;
84
	}
85
86
	/**
87
	 * @param string $station
88
	 */
89
	protected function setStation($station) {
90
		$this->station = $station;
91
	}
92
93
94
}