@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | header('Content-type: text/plain'); |
31 | 31 | |
32 | 32 | $keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array( |
33 | - 'en' => array( |
|
34 | - 'feature' => 'Feature', |
|
35 | - 'background' => 'Background', |
|
36 | - 'scenario' => 'Scenario', |
|
37 | - 'scenario_outline' => 'Scenario Outline', |
|
38 | - 'examples' => 'Examples', |
|
39 | - 'given' => 'Given', |
|
40 | - 'when' => 'When', |
|
41 | - 'then' => 'Then', |
|
42 | - 'and' => 'And', |
|
43 | - 'but' => 'But' |
|
44 | - ), |
|
33 | + 'en' => array( |
|
34 | + 'feature' => 'Feature', |
|
35 | + 'background' => 'Background', |
|
36 | + 'scenario' => 'Scenario', |
|
37 | + 'scenario_outline' => 'Scenario Outline', |
|
38 | + 'examples' => 'Examples', |
|
39 | + 'given' => 'Given', |
|
40 | + 'when' => 'When', |
|
41 | + 'then' => 'Then', |
|
42 | + 'and' => 'And', |
|
43 | + 'but' => 'But' |
|
44 | + ), |
|
45 | 45 | )); |
46 | 46 | $lexer = new Behat\Gherkin\Lexer($keywords); |
47 | 47 | $parser = new Behat\Gherkin\Parser($lexer); |
@@ -51,23 +51,23 @@ discard block |
||
51 | 51 | } |
52 | 52 | catch (Exception $ex) { |
53 | 53 | echo $ex->getMessage() . "\n"; |
54 | - exit; |
|
54 | + exit; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | foreach ($feature->getScenarios() as $scenario) { |
58 | - if ($scenario instanceof OutlineNode) { |
|
59 | - echo $scenario->getExampleTable() . "\n\n"; |
|
60 | - } |
|
61 | - elseif ($scenario instanceof ScenarioNode) { |
|
62 | - foreach ($scenario->getSteps() as $step) { |
|
63 | - foreach ($step->getArguments() as $argument) { |
|
64 | - if ($argument instanceof TableNode) { |
|
65 | - echo $argument . "\n\n"; |
|
66 | - } |
|
67 | - } |
|
68 | - // print_r($step); |
|
69 | - } |
|
70 | - } |
|
58 | + if ($scenario instanceof OutlineNode) { |
|
59 | + echo $scenario->getExampleTable() . "\n\n"; |
|
60 | + } |
|
61 | + elseif ($scenario instanceof ScenarioNode) { |
|
62 | + foreach ($scenario->getSteps() as $step) { |
|
63 | + foreach ($step->getArguments() as $argument) { |
|
64 | + if ($argument instanceof TableNode) { |
|
65 | + echo $argument . "\n\n"; |
|
66 | + } |
|
67 | + } |
|
68 | + // print_r($step); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | print_r($feature); |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | try { |
50 | 50 | $feature = $parser->parse($feature); |
51 | -} |
|
52 | -catch (Exception $ex) { |
|
51 | +} catch (Exception $ex) { |
|
53 | 52 | echo $ex->getMessage() . "\n"; |
54 | 53 | exit; |
55 | 54 | } |
@@ -57,8 +56,7 @@ discard block |
||
57 | 56 | foreach ($feature->getScenarios() as $scenario) { |
58 | 57 | if ($scenario instanceof OutlineNode) { |
59 | 58 | echo $scenario->getExampleTable() . "\n\n"; |
60 | - } |
|
61 | - elseif ($scenario instanceof ScenarioNode) { |
|
59 | + } elseif ($scenario instanceof ScenarioNode) { |
|
62 | 60 | foreach ($scenario->getSteps() as $step) { |
63 | 61 | foreach ($step->getArguments() as $argument) { |
64 | 62 | if ($argument instanceof TableNode) { |
@@ -50,19 +50,19 @@ |
||
50 | 50 | $feature = $parser->parse($feature); |
51 | 51 | } |
52 | 52 | catch (Exception $ex) { |
53 | - echo $ex->getMessage() . "\n"; |
|
53 | + echo $ex->getMessage()."\n"; |
|
54 | 54 | exit; |
55 | 55 | } |
56 | 56 | |
57 | 57 | foreach ($feature->getScenarios() as $scenario) { |
58 | 58 | if ($scenario instanceof OutlineNode) { |
59 | - echo $scenario->getExampleTable() . "\n\n"; |
|
59 | + echo $scenario->getExampleTable()."\n\n"; |
|
60 | 60 | } |
61 | 61 | elseif ($scenario instanceof ScenarioNode) { |
62 | 62 | foreach ($scenario->getSteps() as $step) { |
63 | 63 | foreach ($step->getArguments() as $argument) { |
64 | 64 | if ($argument instanceof TableNode) { |
65 | - echo $argument . "\n\n"; |
|
65 | + echo $argument."\n\n"; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | // print_r($step); |
@@ -17,35 +17,35 @@ |
||
17 | 17 | /** |
18 | 18 | * |
19 | 19 | */ |
20 | - protected function convertor( $toUnit ) { |
|
20 | + protected function convertor($toUnit) { |
|
21 | 21 | return $this->convertUsingMethods($toUnit); |
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * |
26 | 26 | */ |
27 | - protected function kToF( $amount ) { |
|
28 | - return ($amount - 273.15) * 9/5 + 32; |
|
27 | + protected function kToF($amount) { |
|
28 | + return ($amount - 273.15) * 9 / 5 + 32; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * |
33 | 33 | */ |
34 | - protected function fToK( $amount ) { |
|
35 | - return ($amount - 32) * 5/9 + 273.15; |
|
34 | + protected function fToK($amount) { |
|
35 | + return ($amount - 32) * 5 / 9 + 273.15; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * |
40 | 40 | */ |
41 | - protected function kToC( $amount ) { |
|
41 | + protected function kToC($amount) { |
|
42 | 42 | return $amount - 273.15; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * |
47 | 47 | */ |
48 | - protected function cToK( $amount ) { |
|
48 | + protected function cToK($amount) { |
|
49 | 49 | return $amount + 273.15; |
50 | 50 | } |
51 | 51 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * The convertor heart, that every sub class needs |
27 | 27 | */ |
28 | - protected function convertor( $toUnit ) { |
|
28 | + protected function convertor($toUnit) { |
|
29 | 29 | return $this->convertUsingTable($toUnit); |
30 | 30 | } |
31 | 31 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * The convertor heart, that every sub class needs |
27 | 27 | */ |
28 | - protected function convertor( $toUnit ) { |
|
28 | + protected function convertor($toUnit) { |
|
29 | 29 | return $this->convertUsingTable($toUnit); |
30 | 30 | } |
31 | 31 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * The convertor heart, that every sub class needs |
27 | 27 | */ |
28 | - protected function convertor( $toUnit ) { |
|
28 | + protected function convertor($toUnit) { |
|
29 | 29 | return $this->convertUsingTable($toUnit); |
30 | 30 | } |
31 | 31 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | [1, 23, 456], |
13 | 13 | [456, 23, 1], |
14 | 14 | ]); |
15 | -echo $table . "\n\n"; |
|
15 | +echo $table."\n\n"; |
|
16 | 16 | print_r($table); |
17 | 17 | |
18 | 18 | echo "\n\n\n\n"; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | [' 1', '23', '456'], |
24 | 24 | ['456', '23', ' 1'], |
25 | 25 | ]); |
26 | -echo $table . "\n\n"; |
|
26 | +echo $table."\n\n"; |
|
27 | 27 | print_r($table); |
28 | 28 | |
29 | 29 | echo "\n\n\n\n"; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * The convertor heart, that every sub class needs |
27 | 27 | */ |
28 | - protected function convertor( $toUnit ) { |
|
28 | + protected function convertor($toUnit) { |
|
29 | 29 | return $this->convertUsingTable($toUnit); |
30 | 30 | } |
31 | 31 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Convert without the bother of an object |
17 | 17 | */ |
18 | - static public function convert( $amount, $fromUnit, $toUnit ) { |
|
18 | + static public function convert($amount, $fromUnit, $toUnit) { |
|
19 | 19 | $quantity = new static($amount, $fromUnit); |
20 | 20 | return $quantity->to($toUnit); |
21 | 21 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * Check if the given unit is valid for this quantity |
25 | 25 | */ |
26 | - static public function validUnit( $unit ) { |
|
26 | + static public function validUnit($unit) { |
|
27 | 27 | $units = static::$units; |
28 | - if ( isset($units[0]) ) { |
|
28 | + if (isset($units[0])) { |
|
29 | 29 | return in_array($unit, $units); |
30 | 30 | } |
31 | 31 | |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * |
43 | 43 | */ |
44 | - public function __construct( $amount, $unit = null, $convertToDefault = true ) { |
|
44 | + public function __construct($amount, $unit = null, $convertToDefault = true) { |
|
45 | 45 | // Invalid unit! |
46 | - if ( $unit && !static::validUnit($unit) ) { |
|
46 | + if ($unit && !static::validUnit($unit)) { |
|
47 | 47 | $quantity = (new \ReflectionClass(get_called_class()))->getShortName(); |
48 | 48 | throw new ConversionException("Can't import '$quantity' as '$unit'."); |
49 | 49 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->original_unit = $this->unit; |
55 | 55 | |
56 | 56 | // Convert incoming unit into storage unit |
57 | - if ( $convertToDefault && $this->unit != $this::$default_unit ) { |
|
57 | + if ($convertToDefault && $this->unit != $this::$default_unit) { |
|
58 | 58 | $this->amount = $this->to($this::$default_unit); |
59 | 59 | $this->unit = $this::$default_unit; |
60 | 60 | } |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Convert object amount to another unit, and return, don't save |
65 | 65 | */ |
66 | - public function to( $toUnit ) { |
|
67 | - if ( $toUnit === 'base' ) { |
|
66 | + public function to($toUnit) { |
|
67 | + if ($toUnit === 'base') { |
|
68 | 68 | $toUnit = static::BASE_UNIT; |
69 | 69 | } |
70 | 70 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * The convertor heart, that every sub class needs |
76 | 76 | */ |
77 | - abstract protected function convertor( $toUnit ); |
|
77 | + abstract protected function convertor($toUnit); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * The default convertor, using the Quantity's conversion table |
81 | 81 | */ |
82 | - protected function convertUsingTable( $toUnit ) { |
|
82 | + protected function convertUsingTable($toUnit) { |
|
83 | 83 | // Invalid unit! |
84 | - if ( !$this::validUnit($toUnit) ) { |
|
84 | + if (!$this::validUnit($toUnit)) { |
|
85 | 85 | $quantity = (new \ReflectionClass($this))->getShortName(); |
86 | 86 | throw new ConversionException("Can't convert '$quantity' to '$toUnit'."); |
87 | 87 | } |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * Advanded convertor, using unit-base-unit methods |
104 | 104 | */ |
105 | - protected function convertUsingMethods( $toUnit ) { |
|
105 | + protected function convertUsingMethods($toUnit) { |
|
106 | 106 | $amount = $this->amount; |
107 | 107 | |
108 | - if ( $this->unit != $this::BASE_UNIT ) { |
|
109 | - $amount = call_user_func(array($this, $this->unit . 'to' . $this::BASE_UNIT), $amount); |
|
108 | + if ($this->unit != $this::BASE_UNIT) { |
|
109 | + $amount = call_user_func(array($this, $this->unit.'to'.$this::BASE_UNIT), $amount); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( $this::BASE_UNIT != $toUnit ) { |
|
113 | - $amount = call_user_func(array($this, $this::BASE_UNIT . 'to' . $toUnit), $amount); |
|
112 | + if ($this::BASE_UNIT != $toUnit) { |
|
113 | + $amount = call_user_func(array($this, $this::BASE_UNIT.'to'.$toUnit), $amount); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $amount; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * Convert the object to another standard unit |
121 | 121 | */ |
122 | - public function convertTo( $unit ) { |
|
122 | + public function convertTo($unit) { |
|
123 | 123 | $this->amount = $this->to($unit); |
124 | 124 | $this->unit = $unit; |
125 | 125 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function all() { |
131 | 131 | $all = array(); |
132 | - foreach ( $this::$units as $unit => $conversion ) { |
|
133 | - if ( is_int($unit) ) { |
|
132 | + foreach ($this::$units as $unit => $conversion) { |
|
133 | + if (is_int($unit)) { |
|
134 | 134 | $unit = $conversion; |
135 | 135 | } |
136 | 136 |