Stations   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStationsForTerm() 0 12 2
1
<?php
2
/**
3
 * User: ms
4
 * Date: 29.08.15
5
 * Time: 12:37
6
 */
7
8
namespace  Mvg\Parser\Html;
9
10
use phpQuery;
11
use Mvg\Parser\AbstractParser;
12
13
/**
14
 * Class Stations
15
 * @package Mvg\Parser\Html
16
 */
17
class Stations extends AbstractParser {
18
19
	/**
20
	 * @param $searchTerm
21
	 */
22
	public function getStationsForTerm() {
23
		$html = $this->getHtmlResponse();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 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...
24
		$stationObjects = [];
25
		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...
26
		$listItems = pq('li a');
27
		foreach ($listItems as $listItem) {
28
			$stationObject = new \stdClass();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
29
			$stationObject->name = trim(pq($listItem)->html());
30
			$stationObjects[] = $stationObject;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
31
		}
32
		return $stationObjects;
33
	}
34
}