Completed
Push — master ( a6fb71...ab0873 )
by Michael
02:52
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * User: ms
4
 * Date: 28.08.15
5
 * Time: 23:34
6
 * @see this ruby application https://github.com/rmoriz/mvg-live/blob/master/lib/mvg/live.rb
7
 *
8
 * Departures
9
 * http://www.mvg-live.de/ims/dfiStaticAnzeige.svc?haltestelle=Karl-Theodor-Stra%DFe&ubahn=checked&bus=checked&tram=checked&sbahn=checked
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 137 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...
10
 *
11
 * Select Station
12
 * http://www.mvg-live.de/ims/dfiStaticAuswahl.svc?haltestelle=Karl&ubahn=checked&bus=checked&tram=checked&sbahn=checked
13
 */
14
15
use  Mvg\Parser\Html\Departures;
0 ignored issues
show
There must be a single space after the USE keyword
Loading history...
16
use  Mvg\Parser\Html\Stations;
0 ignored issues
show
There must be a single space after the USE keyword
Loading history...
17
use Mvg\TextOutput\Departures as TextOutputDepartures;
18
use Mvg\TextOutput\Stations as TextOutputStations;
19
use Mvg\Factories\Departures as DeparturesFactory;
20
use Mvg\RequestHandler\Html\HttpPostNewsTicker;
21
use Mvg\RequestHandler\Html\HttpGetDepartures;
22
use Mvg\TextOutput\NewsTicker as NewsTickerOutput;
23
24
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
25
26
27
try {
28
	$opts = new Zend\Console\Getopt(
29
		array(
30
			'news|n' => 'Show news about Interferences',
31
			'stations|s=s' => 'Departure Stations - separate multiple stations with ;',
32
			'ends|e=s' => 'end of lines - separate multiple stations with ;'
33
		)
34
	);
35
	$opts->parse();
36
37
} catch (Zend\Console\Exception\RuntimeException $e) {
38
	echo $e->getUsageMessage();
39
	exit;
40
}
41
if (null === $opts->getOption('s')) {
42
	echo $opts->getUsageMessage();
43
	exit;
44
}
45
46
//Stations
47
$stationString = trim($opts->getOption('s'));
0 ignored issues
show
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...
48
$searchForStations = explode(';', $stationString);
49
50
//End of Lines
51
if (null !== $opts->getOption('e')) {
52
	$endStationString = trim($opts->getOption('e'));
0 ignored issues
show
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...
53
	$filterForStations = explode(';', $endStationString);
54
} else {
55
	$filterForStations = array();
56
}
57
58
59
foreach ($searchForStations as $searchForStation) {
60
	$searchForStation = trim($searchForStation);
61
	$http = new HttpGetDepartures('http', 'www.mvg-live.de', 'ims/dfiStaticAuswahl.svc');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 13 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...
62
	$result = $http->getDeparturesForStation($searchForStation);
0 ignored issues
show
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...
63
	$parser = new Departures($result);
0 ignored issues
show
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...
64
	$departures = $parser->getDepartures();
0 ignored issues
show
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...
65
	if (0 === count($departures)) {
66
		echo "Station '" . $searchForStation . "' unknown\n";
67
		echo "Did you mean?\n";
68
		$stationParser = new Stations($result);
69
		echo (new TextOutputStations($stationParser))->getOutput();
70
	} else {
71
		$factory = new DeparturesFactory($parser);
72
		echo (new TextOutputDepartures($factory, $filterForStations))->getOutput();
73
	}
74
}
75
76
77
//Display news from the ticker
78
if (true === $opts->getOption('n')) {
79
	$responseForNewsTicker = (new HttpPostNewsTicker())->doPostRequest();
80
	$newsTickerParser = new \ Mvg\Parser\Html\NewsTicker($responseForNewsTicker);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 6 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...
81
	$interferences = $newsTickerParser->getInterferences();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 9 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...
82
	if (0 < count($interferences)) {
83
		echo "Interferences\n";
84
		echo (new NewsTickerOutput($newsTickerParser))->getOutput();
85
86
	} else {
87
		echo "No Interferences\n";
88
	}
89
}