Passed
Push — master ( 9823d4...48a16c )
by Roberto
02:03
created
src/Object/AddressComponent.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@
 block discarded – undo
19 19
  */
20 20
 class AddressComponent extends AbstractObject {
21 21
 
22
-	/**
23
-	 * @var string
24
-	 */
25
-	protected $long_name = null;
22
+    /**
23
+     * @var string
24
+     */
25
+    protected $long_name = null;
26 26
 
27
-	/**
28
-	 * @var string
29
-	 */
30
-	protected $short_name = null;
27
+    /**
28
+     * @var string
29
+     */
30
+    protected $short_name = null;
31 31
 
32
-	/**
33
-	 * @var array
34
-	 */
35
-	protected $types = null;
32
+    /**
33
+     * @var array
34
+     */
35
+    protected $types = null;
36 36
 
37
-	/**
38
-	 * @var array
39
-	 */
40
-	protected $typeCheck = [
41
-		AddressComponentFields::LONG_NAME  => 'string',
42
-		AddressComponentFields::SHORT_NAME => 'string',
43
-		AddressComponentFields::TYPES      => 'array'
44
-	];
37
+    /**
38
+     * @var array
39
+     */
40
+    protected $typeCheck = [
41
+        AddressComponentFields::LONG_NAME  => 'string',
42
+        AddressComponentFields::SHORT_NAME => 'string',
43
+        AddressComponentFields::TYPES      => 'array'
44
+    ];
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
src/Object/Address.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@
 block discarded – undo
18 18
  */
19 19
 class Address extends AbstractCollection {
20 20
 
21
-	/**
22
-	 * @param $item
23
-	 *
24
-	 * @return AddressComponent
25
-	 */
26
-	protected function parseItem($item) {
21
+    /**
22
+     * @param $item
23
+     *
24
+     * @return AddressComponent
25
+     */
26
+    protected function parseItem($item) {
27 27
 
28
-		return ($item instanceof AddressComponent) ? $item : new AddressComponent($item);
29
-	}
28
+        return ($item instanceof AddressComponent) ? $item : new AddressComponent($item);
29
+    }
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Object/LatLngBounds.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@
 block discarded – undo
21 21
  */
22 22
 class LatLngBounds extends AbstractObject {
23 23
 
24
-	/**
25
-	 * @var LatLng
26
-	 */
27
-	protected $northeast = null;
24
+    /**
25
+     * @var LatLng
26
+     */
27
+    protected $northeast = null;
28 28
 
29
-	/**
30
-	 * @var LatLng
31
-	 */
32
-	protected $southwest = null;
29
+    /**
30
+     * @var LatLng
31
+     */
32
+    protected $southwest = null;
33 33
 
34
-	/**
35
-	 * @var array
36
-	 */
37
-	protected $typeCheck = [
38
-		LatLngBoundsFields::NORTHEAST => LatLng::class,
39
-		LatLngBoundsFields::SOUTHWEST => LatLng::class
40
-	];
34
+    /**
35
+     * @var array
36
+     */
37
+    protected $typeCheck = [
38
+        LatLngBoundsFields::NORTHEAST => LatLng::class,
39
+        LatLngBoundsFields::SOUTHWEST => LatLng::class
40
+    ];
41 41
 
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/Object/Geometry.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@
 block discarded – undo
25 25
  */
26 26
 class Geometry extends AbstractObject {
27 27
 
28
-	/**
29
-	 * @var Location
30
-	 */
31
-	protected $location = null;
28
+    /**
29
+     * @var Location
30
+     */
31
+    protected $location = null;
32 32
 
33
-	/**
34
-	 * @var Viewport
35
-	 */
36
-	protected $viewport = null;
33
+    /**
34
+     * @var Viewport
35
+     */
36
+    protected $viewport = null;
37 37
 
38
-	/**
39
-	 * @var string
40
-	 */
41
-	protected $location_type = null;
38
+    /**
39
+     * @var string
40
+     */
41
+    protected $location_type = null;
42 42
 
43
-	/**
44
-	 * @var array
45
-	 */
46
-	protected $typeCheck = [
47
-		GeometryFields::LOCATION      => Location::class,
48
-		GeometryFields::VIEWPORT      => Viewport::class,
49
-		GeometryFields::LOCATION_TYPE => 'string'
50
-	];
43
+    /**
44
+     * @var array
45
+     */
46
+    protected $typeCheck = [
47
+        GeometryFields::LOCATION      => Location::class,
48
+        GeometryFields::VIEWPORT      => Viewport::class,
49
+        GeometryFields::LOCATION_TYPE => 'string'
50
+    ];
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
src/Object/LatLng.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -21,53 +21,53 @@
 block discarded – undo
21 21
  */
22 22
 class LatLng extends AbstractObject {
23 23
 
24
-	/**
25
-	 * @var float
26
-	 */
27
-	protected $lat = 0;
24
+    /**
25
+     * @var float
26
+     */
27
+    protected $lat = 0;
28 28
 
29
-	/**
30
-	 * @var float
31
-	 */
32
-	protected $lng = 0;
29
+    /**
30
+     * @var float
31
+     */
32
+    protected $lng = 0;
33 33
 
34
-	/**
35
-	 * @var array
36
-	 */
37
-	protected $typeCheck = [
38
-		LatLngFields::LAT => 'float',
39
-		LatLngFields::LNG => 'float',
40
-	];
34
+    /**
35
+     * @var array
36
+     */
37
+    protected $typeCheck = [
38
+        LatLngFields::LAT => 'float',
39
+        LatLngFields::LNG => 'float',
40
+    ];
41 41
 
42
-	/**
43
-	 * Return the latitude, 0 if null
44
-	 *
45
-	 * @return string
46
-	 */
47
-	public function getLat(): string {
42
+    /**
43
+     * Return the latitude, 0 if null
44
+     *
45
+     * @return string
46
+     */
47
+    public function getLat(): string {
48 48
 
49
-		return $this->lat ?? 0;
50
-	}
49
+        return $this->lat ?? 0;
50
+    }
51 51
 
52
-	/**
53
-	 * Return the longitude, 0 if null
54
-	 *
55
-	 * @return string
56
-	 */
57
-	public function getLng(): string {
52
+    /**
53
+     * Return the longitude, 0 if null
54
+     *
55
+     * @return string
56
+     */
57
+    public function getLng(): string {
58 58
 
59
-		return $this->lng ?? 0;
60
-	}
59
+        return $this->lng ?? 0;
60
+    }
61 61
 
62
-	/**
63
-	 * @return string
64
-	 */
65
-	public function __toString(): string {
62
+    /**
63
+     * @return string
64
+     */
65
+    public function __toString(): string {
66 66
 
67
-		return implode(',', [
68
-			$this->getLat(),
69
-			$this->getLng()
70
-		]);
71
-	}
67
+        return implode(',', [
68
+            $this->getLat(),
69
+            $this->getLng()
70
+        ]);
71
+    }
72 72
 
73 73
 }
74 74
\ No newline at end of file
Please login to merge, or discard this patch.
src/Abstracts/AbstractObject.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		foreach ($this->typeCheck as $field_name => $field_type) {
55 55
 			if (empty($args[$field_name]) || is_null($args[$field_name])) {
56 56
 				if ($this->isFieldRequired($field_name)) {
57
-					$this->addError('Missing "' . $field_name . '" in ' . static::class);
57
+					$this->addError('Missing "'.$field_name.'" in '.static::class);
58 58
 				}
59 59
 			} else {
60 60
 				$this->$field_name = $this->parseFieldValue($field_type, $args[$field_name]);
Please login to merge, or discard this patch.
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -19,158 +19,158 @@
 block discarded – undo
19 19
  */
20 20
 abstract class AbstractObject {
21 21
 
22
-	/**
23
-	 * @var array
24
-	 */
25
-	protected $typeCheck = [];
26
-
27
-	/**
28
-	 * @var array
29
-	 */
30
-	protected $required = [];
31
-
32
-	/**
33
-	 * @var array
34
-	 */
35
-	protected $errors = [];
36
-
37
-	/**
38
-	 * AbstractObject constructor.
39
-	 *
40
-	 * @param array $args
41
-	 */
42
-	public function __construct(?array $args = []) {
43
-
44
-		$this->setArgs($args);
45
-	}
46
-
47
-	/**
48
-	 * @param array $args
49
-	 *
50
-	 * @throws Exception
51
-	 */
52
-	protected function setArgs(array $args) {
53
-
54
-		foreach ($this->typeCheck as $field_name => $field_type) {
55
-			if (empty($args[$field_name]) || is_null($args[$field_name])) {
56
-				if ($this->isFieldRequired($field_name)) {
57
-					$this->addError('Missing "' . $field_name . '" in ' . static::class);
58
-				}
59
-			} else {
60
-				$this->$field_name = $this->parseFieldValue($field_type, $args[$field_name]);
61
-			}
62
-		}
63
-		$this->throwErrors();
64
-	}
65
-
66
-	/**
67
-	 * @param string $field_name
68
-	 *
69
-	 * @return bool
70
-	 */
71
-	protected function isFieldRequired(string $field_name): bool {
72
-
73
-		return in_array($field_name, $this->required);
74
-	}
75
-
76
-	/**
77
-	 * @param string $error
78
-	 *
79
-	 * @return array
80
-	 */
81
-	protected function addError(string $error): array {
82
-
83
-		array_push($this->errors, $error);
84
-
85
-		return $this->errors;
86
-	}
87
-
88
-	/**
89
-	 * @param string $field_type
90
-	 * @param string $field_value
91
-	 *
92
-	 * @return mixed
93
-	 */
94
-	protected function parseFieldValue(string $field_type, $field_value) {
95
-
96
-		switch ($field_type) {
97
-			case 'string':
98
-			case 'int':
99
-			case 'float':
100
-			case 'array':
101
-				return $field_value;
102
-			default:
103
-				return ($field_value instanceof $field_type) ? $field_value : new $field_type($field_value);
104
-		}
105
-	}
106
-
107
-	/**
108
-	 * @throws Exception
109
-	 */
110
-	protected function throwErrors() {
111
-
112
-		if (count($this->errors)) {
113
-			throw new Exception(implode(', ', $this->errors));
114
-		}
115
-	}
116
-
117
-	/**
118
-	 * @return string
119
-	 */
120
-	public function toJson(): string {
121
-
122
-		return json_encode($this->toArray());
123
-	}
124
-
125
-	/**
126
-	 * @return array
127
-	 */
128
-	public function toArray(): array {
129
-
130
-		$fields = get_object_vars($this);
131
-
132
-		foreach ($fields as $field_name => $field_value) {
133
-
134
-			if (!is_scalar($field_value) && method_exists($field_value, 'toJson')) {
135
-				$fields[$field_name] = $field_value->toArray();
136
-			}
137
-		}
138
-
139
-		return $fields;
140
-	}
141
-
142
-	/**
143
-	 * @return string
144
-	 */
145
-	public function __toString(): string {
146
-
147
-		return implode(',', $this->toArray());
148
-	}
149
-
150
-	/**
151
-	 * @param $name
152
-	 * @param $arguments
153
-	 *
154
-	 * @return mixed
155
-	 */
156
-	public function __call($name, $arguments) {
157
-
158
-		preg_match('/(?<=(g|s)et)([A-Za-z0-9])\w+/', $name, $match);
159
-
160
-		$camel_field = (empty($match[0])) ? '' : $match[0];
161
-
162
-		$snake_field = camel2Snake($camel_field);
163
-
164
-		$field_type = (empty($this->typeCheck[$snake_field])) ? null : $this->typeCheck[$snake_field];
165
-
166
-		if (!empty($match[1]) && $field_type) {
167
-			switch ($match[1]) {
168
-				case 's':
169
-					return $this->$snake_field = $this->parseFieldValue($field_type, current($arguments));
170
-				case 'g':
171
-					return $this->$snake_field;
172
-			}
173
-		}
174
-	}
22
+    /**
23
+     * @var array
24
+     */
25
+    protected $typeCheck = [];
26
+
27
+    /**
28
+     * @var array
29
+     */
30
+    protected $required = [];
31
+
32
+    /**
33
+     * @var array
34
+     */
35
+    protected $errors = [];
36
+
37
+    /**
38
+     * AbstractObject constructor.
39
+     *
40
+     * @param array $args
41
+     */
42
+    public function __construct(?array $args = []) {
43
+
44
+        $this->setArgs($args);
45
+    }
46
+
47
+    /**
48
+     * @param array $args
49
+     *
50
+     * @throws Exception
51
+     */
52
+    protected function setArgs(array $args) {
53
+
54
+        foreach ($this->typeCheck as $field_name => $field_type) {
55
+            if (empty($args[$field_name]) || is_null($args[$field_name])) {
56
+                if ($this->isFieldRequired($field_name)) {
57
+                    $this->addError('Missing "' . $field_name . '" in ' . static::class);
58
+                }
59
+            } else {
60
+                $this->$field_name = $this->parseFieldValue($field_type, $args[$field_name]);
61
+            }
62
+        }
63
+        $this->throwErrors();
64
+    }
65
+
66
+    /**
67
+     * @param string $field_name
68
+     *
69
+     * @return bool
70
+     */
71
+    protected function isFieldRequired(string $field_name): bool {
72
+
73
+        return in_array($field_name, $this->required);
74
+    }
75
+
76
+    /**
77
+     * @param string $error
78
+     *
79
+     * @return array
80
+     */
81
+    protected function addError(string $error): array {
82
+
83
+        array_push($this->errors, $error);
84
+
85
+        return $this->errors;
86
+    }
87
+
88
+    /**
89
+     * @param string $field_type
90
+     * @param string $field_value
91
+     *
92
+     * @return mixed
93
+     */
94
+    protected function parseFieldValue(string $field_type, $field_value) {
95
+
96
+        switch ($field_type) {
97
+            case 'string':
98
+            case 'int':
99
+            case 'float':
100
+            case 'array':
101
+                return $field_value;
102
+            default:
103
+                return ($field_value instanceof $field_type) ? $field_value : new $field_type($field_value);
104
+        }
105
+    }
106
+
107
+    /**
108
+     * @throws Exception
109
+     */
110
+    protected function throwErrors() {
111
+
112
+        if (count($this->errors)) {
113
+            throw new Exception(implode(', ', $this->errors));
114
+        }
115
+    }
116
+
117
+    /**
118
+     * @return string
119
+     */
120
+    public function toJson(): string {
121
+
122
+        return json_encode($this->toArray());
123
+    }
124
+
125
+    /**
126
+     * @return array
127
+     */
128
+    public function toArray(): array {
129
+
130
+        $fields = get_object_vars($this);
131
+
132
+        foreach ($fields as $field_name => $field_value) {
133
+
134
+            if (!is_scalar($field_value) && method_exists($field_value, 'toJson')) {
135
+                $fields[$field_name] = $field_value->toArray();
136
+            }
137
+        }
138
+
139
+        return $fields;
140
+    }
141
+
142
+    /**
143
+     * @return string
144
+     */
145
+    public function __toString(): string {
146
+
147
+        return implode(',', $this->toArray());
148
+    }
149
+
150
+    /**
151
+     * @param $name
152
+     * @param $arguments
153
+     *
154
+     * @return mixed
155
+     */
156
+    public function __call($name, $arguments) {
157
+
158
+        preg_match('/(?<=(g|s)et)([A-Za-z0-9])\w+/', $name, $match);
159
+
160
+        $camel_field = (empty($match[0])) ? '' : $match[0];
161
+
162
+        $snake_field = camel2Snake($camel_field);
163
+
164
+        $field_type = (empty($this->typeCheck[$snake_field])) ? null : $this->typeCheck[$snake_field];
165
+
166
+        if (!empty($match[1]) && $field_type) {
167
+            switch ($match[1]) {
168
+                case 's':
169
+                    return $this->$snake_field = $this->parseFieldValue($field_type, current($arguments));
170
+                case 'g':
171
+                    return $this->$snake_field;
172
+            }
173
+        }
174
+    }
175 175
 
176 176
 }
177 177
\ No newline at end of file
Please login to merge, or discard this patch.
src/Abstracts/AbstractCollection.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -16,169 +16,169 @@
 block discarded – undo
16 16
  */
17 17
 abstract class AbstractCollection {
18 18
 
19
-	/**
20
-	 * @var array
21
-	 */
22
-	protected $items = [];
23
-
24
-	/**
25
-	 * @var int
26
-	 */
27
-	protected $index = 0;
28
-
29
-	/**
30
-	 * AbstractCollection constructor.
31
-	 *
32
-	 * @param null|array $items
33
-	 */
34
-	public function __construct(?array $items = []) {
35
-
36
-		$this->setItems($items);
37
-	}
38
-
39
-	/**
40
-	 * @param array $items
41
-	 *
42
-	 * @return AbstractCollection
43
-	 */
44
-	protected function setItems(?array $items = []) {
45
-
46
-		if (is_array($items) && count($items)) {
47
-			foreach ($items as $item) {
48
-				$this->addItem($item);
49
-			}
50
-		}
51
-
52
-		return $this;
53
-	}
54
-
55
-	/**
56
-	 * @param $item
57
-	 *
58
-	 * @return AbstractCollection
59
-	 */
60
-	public function addItem($item) {
61
-
62
-		$item = $this->parseItem($item);
63
-		array_push($this->items, $item);
64
-
65
-		return $this;
66
-	}
67
-
68
-	/**
69
-	 * @param $item
70
-	 *
71
-	 * @return mixed
72
-	 */
73
-	protected function parseItem($item) {
74
-
75
-		return $item;
76
-	}
77
-
78
-	/**
79
-	 * @return array
80
-	 */
81
-	public function toArray(): array {
82
-
83
-		return $this->items;
84
-	}
85
-
86
-	/**
87
-	 * @param $index
88
-	 *
89
-	 * @return mixed|null
90
-	 */
91
-	public function get(int $index) {
92
-
93
-		return isset($this->items[$index]) ? $this->items[$index] : null;
94
-	}
95
-
96
-	/**
97
-	 * @return int
98
-	 */
99
-	public function count(): int {
100
-
101
-		return count($this->items);
102
-	}
103
-
104
-	/**
105
-	 * @return string
106
-	 */
107
-	public function toJson(): string {
108
-
109
-		return json_encode($this->toArray());
110
-	}
111
-
112
-	/**
113
-	 * @return string
114
-	 */
115
-	public function __toString(): string {
116
-
117
-		return implode(',', $this->toArray());
118
-	}
119
-
120
-	/**
121
-	 * @return int
122
-	 */
123
-	public function getLastIndex(): int {
124
-
125
-		$last_position = $this->count() - 1;
126
-
127
-		return ($last_position) < 0 ? 0 : $last_position;
128
-	}
129
-
130
-	/**
131
-	 * Move the index at the specified position
132
-	 *
133
-	 * @param int|null $index
134
-	 *
135
-	 * @return mixed|null
136
-	 */
137
-	public function seek(?int $index = 0) {
138
-
139
-		$this->index = ($index < $this->count()) ? $index : $this->getLastIndex();
140
-
141
-		return $this->get($this->index);
142
-	}
143
-
144
-	/**
145
-	 * Return the current position of the index
146
-	 *
147
-	 * @return int
148
-	 */
149
-	public function position(): int {
150
-
151
-		return $this->index;
152
-	}
153
-
154
-	/**
155
-	 * Return the current object
156
-	 *
157
-	 * @return mixed|null
158
-	 */
159
-	public function current() {
160
-
161
-		return $this->get($this->index);
162
-	}
163
-
164
-	/**
165
-	 * Move index to first position and return current element
166
-	 *
167
-	 * @return mixed|null
168
-	 */
169
-	public function first() {
170
-
171
-		return $this->seek();
172
-	}
173
-
174
-	/**
175
-	 * Move index at the end of collection and return current element
176
-	 *
177
-	 * @return mixed|null
178
-	 */
179
-	public function last() {
180
-
181
-		return $this->seek($this->getLastIndex());
182
-	}
19
+    /**
20
+     * @var array
21
+     */
22
+    protected $items = [];
23
+
24
+    /**
25
+     * @var int
26
+     */
27
+    protected $index = 0;
28
+
29
+    /**
30
+     * AbstractCollection constructor.
31
+     *
32
+     * @param null|array $items
33
+     */
34
+    public function __construct(?array $items = []) {
35
+
36
+        $this->setItems($items);
37
+    }
38
+
39
+    /**
40
+     * @param array $items
41
+     *
42
+     * @return AbstractCollection
43
+     */
44
+    protected function setItems(?array $items = []) {
45
+
46
+        if (is_array($items) && count($items)) {
47
+            foreach ($items as $item) {
48
+                $this->addItem($item);
49
+            }
50
+        }
51
+
52
+        return $this;
53
+    }
54
+
55
+    /**
56
+     * @param $item
57
+     *
58
+     * @return AbstractCollection
59
+     */
60
+    public function addItem($item) {
61
+
62
+        $item = $this->parseItem($item);
63
+        array_push($this->items, $item);
64
+
65
+        return $this;
66
+    }
67
+
68
+    /**
69
+     * @param $item
70
+     *
71
+     * @return mixed
72
+     */
73
+    protected function parseItem($item) {
74
+
75
+        return $item;
76
+    }
77
+
78
+    /**
79
+     * @return array
80
+     */
81
+    public function toArray(): array {
82
+
83
+        return $this->items;
84
+    }
85
+
86
+    /**
87
+     * @param $index
88
+     *
89
+     * @return mixed|null
90
+     */
91
+    public function get(int $index) {
92
+
93
+        return isset($this->items[$index]) ? $this->items[$index] : null;
94
+    }
95
+
96
+    /**
97
+     * @return int
98
+     */
99
+    public function count(): int {
100
+
101
+        return count($this->items);
102
+    }
103
+
104
+    /**
105
+     * @return string
106
+     */
107
+    public function toJson(): string {
108
+
109
+        return json_encode($this->toArray());
110
+    }
111
+
112
+    /**
113
+     * @return string
114
+     */
115
+    public function __toString(): string {
116
+
117
+        return implode(',', $this->toArray());
118
+    }
119
+
120
+    /**
121
+     * @return int
122
+     */
123
+    public function getLastIndex(): int {
124
+
125
+        $last_position = $this->count() - 1;
126
+
127
+        return ($last_position) < 0 ? 0 : $last_position;
128
+    }
129
+
130
+    /**
131
+     * Move the index at the specified position
132
+     *
133
+     * @param int|null $index
134
+     *
135
+     * @return mixed|null
136
+     */
137
+    public function seek(?int $index = 0) {
138
+
139
+        $this->index = ($index < $this->count()) ? $index : $this->getLastIndex();
140
+
141
+        return $this->get($this->index);
142
+    }
143
+
144
+    /**
145
+     * Return the current position of the index
146
+     *
147
+     * @return int
148
+     */
149
+    public function position(): int {
150
+
151
+        return $this->index;
152
+    }
153
+
154
+    /**
155
+     * Return the current object
156
+     *
157
+     * @return mixed|null
158
+     */
159
+    public function current() {
160
+
161
+        return $this->get($this->index);
162
+    }
163
+
164
+    /**
165
+     * Move index to first position and return current element
166
+     *
167
+     * @return mixed|null
168
+     */
169
+    public function first() {
170
+
171
+        return $this->seek();
172
+    }
173
+
174
+    /**
175
+     * Move index at the end of collection and return current element
176
+     *
177
+     * @return mixed|null
178
+     */
179
+    public function last() {
180
+
181
+        return $this->seek($this->getLastIndex());
182
+    }
183 183
 
184 184
 }
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
src/GoogleMapsApi.php 2 patches
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -23,250 +23,250 @@
 block discarded – undo
23 23
  */
24 24
 class GoogleMapsApi {
25 25
 
26
-	/**
27
-	 * Google Maps Geocode Service API url
28
-	 * @var string
29
-	 */
30
-	private $api_url = "https://maps.googleapis.com/maps/api/";
31
-
32
-	/**
33
-	 * your own Google Maps API key
34
-	 * @var string
35
-	 * @see https://developers.google.com/maps/documentation/javascript/get-api-key
36
-	 */
37
-	private $key = '';
38
-
39
-	/**
40
-	 * Google Maps API sensor
41
-	 * @var string - true|false
42
-	 */
43
-	private $sensor = 'false';
44
-
45
-	/**
46
-	 * Google Maps API service name
47
-	 * @var string
48
-	 */
49
-	private $service_endpoint = '';
50
-
51
-	/**
52
-	 * @var string
53
-	 */
54
-	private $response = null;
55
-
56
-	/**
57
-	 * @var GoogleMapsClient
58
-	 */
59
-	private $client = null;
60
-
61
-	/**
62
-	 * @var string
63
-	 */
64
-	private $type = null;
65
-
66
-	/**
67
-	 * @var GoogleMapsApi
68
-	 */
69
-	protected static $instance = null;
70
-
71
-	/**
72
-	 * @var GoogleMapsRequest
73
-	 */
74
-	protected $request = null;
75
-
76
-	/**
77
-	 * GoogleMapsApi constructor.
78
-	 *
79
-	 * @param array $config
80
-	 */
81
-	public function __construct(array $config = []) {
82
-
83
-		// Set "API key"
84
-		$key = (empty($config[GoogleMapsApiConfigFields::KEY])) ? '' : $config[GoogleMapsApiConfigFields::KEY];
85
-		$this->setKey($key);
86
-
87
-		// Set "sensor"
88
-		$sensor = (empty($config[GoogleMapsApiConfigFields::SENSOR])) ? '' : $config[GoogleMapsApiConfigFields::SENSOR];
89
-		$this->setSensor($sensor);
90
-
91
-		// Set the endpoint
92
-		$service_endpoint = (empty($config[GoogleMapsApiConfigFields::SERVICE_ENDPOINT])) ? '' : $config[GoogleMapsApiConfigFields::SERVICE_ENDPOINT];
93
-		$this->setServiceEndpoint($service_endpoint);
94
-
95
-		// Set Client
96
-		$this->setClient();
97
-	}
98
-
99
-	/**
100
-	 * @return string
101
-	 */
102
-	public function getApiUrl(): string {
103
-
104
-		return $this->api_url;
105
-	}
106
-
107
-	/**
108
-	 * @param string $key
109
-	 *
110
-	 * @return GoogleMapsApi
111
-	 */
112
-	public function setKey(string $key): GoogleMapsApi {
113
-
114
-		$this->key = $key;
115
-
116
-		return $this;
117
-	}
118
-
119
-	/**
120
-	 * @return string
121
-	 */
122
-	public function getKey(): string {
123
-
124
-		return $this->key;
125
-	}
126
-
127
-	/**
128
-	 * Set sensor parameter
129
-	 *
130
-	 * @param bool $sensor
131
-	 *
132
-	 * @return GoogleMapsApi
133
-	 */
134
-	public function setSensor(bool $sensor): GoogleMapsApi {
135
-
136
-		if ($sensor === false) {
137
-			$sensor = 'false';
138
-		}
139
-		$this->sensor = $sensor;
140
-
141
-		return $this;
142
-	}
143
-
144
-	/**
145
-	 * @return string
146
-	 */
147
-	public function getSensor(): string {
148
-
149
-		return $this->sensor ? 'true' : 'false';
150
-	}
151
-
152
-	/**
153
-	 * @param GoogleMapsClient|null $client
154
-	 *
155
-	 * @return GoogleMapsApi
156
-	 */
157
-	public function setClient(?GoogleMapsClient $client = null): GoogleMapsApi {
158
-
159
-		$this->client = $client ?? new GoogleMapsClient();
160
-
161
-		return $this;
162
-	}
163
-
164
-	/**
165
-	 * @return GoogleMapsClient
166
-	 */
167
-	public function getClient() {
168
-
169
-		return $this->client;
170
-	}
171
-
172
-	/**
173
-	 * @return GoogleMapsRequest
174
-	 */
175
-	public function getRequest(): GoogleMapsRequest {
176
-
177
-		return $this->request;
178
-	}
179
-
180
-	/**
181
-	 * @return string
182
-	 */
183
-	public function getServiceEndpoint(): string {
184
-
185
-		return $this->service_endpoint;
186
-	}
187
-
188
-	/**
189
-	 * @param string $service_endpoint
190
-	 */
191
-	public function setServiceEndpoint(string $service_endpoint) {
192
-
193
-		$this->service_endpoint = $service_endpoint;
194
-	}
195
-
196
-	/**
197
-	 * @param string $type
198
-	 *
199
-	 * @return GoogleMapsApi
200
-	 */
201
-	protected function setType(string $type): GoogleMapsApi {
202
-
203
-		$this->type = $type;
204
-
205
-		return $this;
206
-	}
207
-
208
-	/**
209
-	 * @return string
210
-	 * @throws RequestException
211
-	 */
212
-	public function getUrl(): string {
26
+    /**
27
+     * Google Maps Geocode Service API url
28
+     * @var string
29
+     */
30
+    private $api_url = "https://maps.googleapis.com/maps/api/";
31
+
32
+    /**
33
+     * your own Google Maps API key
34
+     * @var string
35
+     * @see https://developers.google.com/maps/documentation/javascript/get-api-key
36
+     */
37
+    private $key = '';
38
+
39
+    /**
40
+     * Google Maps API sensor
41
+     * @var string - true|false
42
+     */
43
+    private $sensor = 'false';
44
+
45
+    /**
46
+     * Google Maps API service name
47
+     * @var string
48
+     */
49
+    private $service_endpoint = '';
50
+
51
+    /**
52
+     * @var string
53
+     */
54
+    private $response = null;
55
+
56
+    /**
57
+     * @var GoogleMapsClient
58
+     */
59
+    private $client = null;
60
+
61
+    /**
62
+     * @var string
63
+     */
64
+    private $type = null;
65
+
66
+    /**
67
+     * @var GoogleMapsApi
68
+     */
69
+    protected static $instance = null;
70
+
71
+    /**
72
+     * @var GoogleMapsRequest
73
+     */
74
+    protected $request = null;
75
+
76
+    /**
77
+     * GoogleMapsApi constructor.
78
+     *
79
+     * @param array $config
80
+     */
81
+    public function __construct(array $config = []) {
82
+
83
+        // Set "API key"
84
+        $key = (empty($config[GoogleMapsApiConfigFields::KEY])) ? '' : $config[GoogleMapsApiConfigFields::KEY];
85
+        $this->setKey($key);
86
+
87
+        // Set "sensor"
88
+        $sensor = (empty($config[GoogleMapsApiConfigFields::SENSOR])) ? '' : $config[GoogleMapsApiConfigFields::SENSOR];
89
+        $this->setSensor($sensor);
90
+
91
+        // Set the endpoint
92
+        $service_endpoint = (empty($config[GoogleMapsApiConfigFields::SERVICE_ENDPOINT])) ? '' : $config[GoogleMapsApiConfigFields::SERVICE_ENDPOINT];
93
+        $this->setServiceEndpoint($service_endpoint);
94
+
95
+        // Set Client
96
+        $this->setClient();
97
+    }
98
+
99
+    /**
100
+     * @return string
101
+     */
102
+    public function getApiUrl(): string {
103
+
104
+        return $this->api_url;
105
+    }
106
+
107
+    /**
108
+     * @param string $key
109
+     *
110
+     * @return GoogleMapsApi
111
+     */
112
+    public function setKey(string $key): GoogleMapsApi {
113
+
114
+        $this->key = $key;
115
+
116
+        return $this;
117
+    }
118
+
119
+    /**
120
+     * @return string
121
+     */
122
+    public function getKey(): string {
123
+
124
+        return $this->key;
125
+    }
126
+
127
+    /**
128
+     * Set sensor parameter
129
+     *
130
+     * @param bool $sensor
131
+     *
132
+     * @return GoogleMapsApi
133
+     */
134
+    public function setSensor(bool $sensor): GoogleMapsApi {
135
+
136
+        if ($sensor === false) {
137
+            $sensor = 'false';
138
+        }
139
+        $this->sensor = $sensor;
140
+
141
+        return $this;
142
+    }
143
+
144
+    /**
145
+     * @return string
146
+     */
147
+    public function getSensor(): string {
148
+
149
+        return $this->sensor ? 'true' : 'false';
150
+    }
151
+
152
+    /**
153
+     * @param GoogleMapsClient|null $client
154
+     *
155
+     * @return GoogleMapsApi
156
+     */
157
+    public function setClient(?GoogleMapsClient $client = null): GoogleMapsApi {
158
+
159
+        $this->client = $client ?? new GoogleMapsClient();
160
+
161
+        return $this;
162
+    }
163
+
164
+    /**
165
+     * @return GoogleMapsClient
166
+     */
167
+    public function getClient() {
168
+
169
+        return $this->client;
170
+    }
171
+
172
+    /**
173
+     * @return GoogleMapsRequest
174
+     */
175
+    public function getRequest(): GoogleMapsRequest {
176
+
177
+        return $this->request;
178
+    }
179
+
180
+    /**
181
+     * @return string
182
+     */
183
+    public function getServiceEndpoint(): string {
184
+
185
+        return $this->service_endpoint;
186
+    }
187
+
188
+    /**
189
+     * @param string $service_endpoint
190
+     */
191
+    public function setServiceEndpoint(string $service_endpoint) {
192
+
193
+        $this->service_endpoint = $service_endpoint;
194
+    }
195
+
196
+    /**
197
+     * @param string $type
198
+     *
199
+     * @return GoogleMapsApi
200
+     */
201
+    protected function setType(string $type): GoogleMapsApi {
202
+
203
+        $this->type = $type;
204
+
205
+        return $this;
206
+    }
207
+
208
+    /**
209
+     * @return string
210
+     * @throws RequestException
211
+     */
212
+    public function getUrl(): string {
213 213
 
214
-		$service_endpoint = $this->getServiceEndpoint();
215
-		if (!$service_endpoint) {
216
-			throw new RequestException('Service name missing!');
217
-		}
218
-
219
-		return $this->api_url . $service_endpoint . '/' . GoogleMapsResponseFormat::JSON;
220
-	}
221
-
222
-	/**
223
-	 * @param GoogleMapsRequest $request
224
-	 *
225
-	 * @return GoogleMapsApi
226
-	 */
227
-	public function setRequest(GoogleMapsRequest $request) {
228
-
229
-		$this->request = $request;
230
-
231
-		return $this;
232
-	}
214
+        $service_endpoint = $this->getServiceEndpoint();
215
+        if (!$service_endpoint) {
216
+            throw new RequestException('Service name missing!');
217
+        }
218
+
219
+        return $this->api_url . $service_endpoint . '/' . GoogleMapsResponseFormat::JSON;
220
+    }
221
+
222
+    /**
223
+     * @param GoogleMapsRequest $request
224
+     *
225
+     * @return GoogleMapsApi
226
+     */
227
+    public function setRequest(GoogleMapsRequest $request) {
228
+
229
+        $this->request = $request;
230
+
231
+        return $this;
232
+    }
233 233
 
234
-	/**
235
-	 * @return string
236
-	 */
237
-	public function getQuery(): string {
234
+    /**
235
+     * @return string
236
+     */
237
+    public function getQuery(): string {
238 238
 
239
-		$api_query = http_build_query([
240
-			GoogleMapsRequestFields::KEY    => $this->getKey(),
241
-			GoogleMapsRequestFields::SENSOR => $this->getSensor(),
242
-		]);
239
+        $api_query = http_build_query([
240
+            GoogleMapsRequestFields::KEY    => $this->getKey(),
241
+            GoogleMapsRequestFields::SENSOR => $this->getSensor(),
242
+        ]);
243 243
 
244
-		$request_query = $this->getRequest()->getQuery();
244
+        $request_query = $this->getRequest()->getQuery();
245 245
 
246
-		return implode('&', [
247
-			$api_query,
248
-			$request_query
249
-		]);
250
-	}
246
+        return implode('&', [
247
+            $api_query,
248
+            $request_query
249
+        ]);
250
+    }
251 251
 
252
-	/**
253
-	 * Perform the Google Maps API call
254
-	 *
255
-	 * @param GoogleMapsRequest $request
256
-	 *
257
-	 * @return Http\GoogleMapsResponse|string
258
-	 */
259
-	public function get(GoogleMapsRequest $request) {
252
+    /**
253
+     * Perform the Google Maps API call
254
+     *
255
+     * @param GoogleMapsRequest $request
256
+     *
257
+     * @return Http\GoogleMapsResponse|string
258
+     */
259
+    public function get(GoogleMapsRequest $request) {
260 260
 
261
-		$this->setRequest($request);
261
+        $this->setRequest($request);
262 262
 
263
-		$url = $this->getUrl();
263
+        $url = $this->getUrl();
264 264
 
265
-		$query = $this->getQuery();
265
+        $query = $this->getQuery();
266 266
 
267
-		$this->response = $this->getClient()->get($url, $query);
267
+        $this->response = $this->getClient()->get($url, $query);
268 268
 
269
-		return $this->response;
270
-	}
269
+        return $this->response;
270
+    }
271 271
 
272 272
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@
 block discarded – undo
216 216
 			throw new RequestException('Service name missing!');
217 217
 		}
218 218
 
219
-		return $this->api_url . $service_endpoint . '/' . GoogleMapsResponseFormat::JSON;
219
+		return $this->api_url.$service_endpoint.'/'.GoogleMapsResponseFormat::JSON;
220 220
 	}
221 221
 
222 222
 	/**
Please login to merge, or discard this patch.
src/Enum/GoogleMapsResponseFormat.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@
 block discarded – undo
16 16
  */
17 17
 class GoogleMapsResponseFormat {
18 18
 
19
-	/**
20
-	 * string: json
21
-	 */
22
-	const JSON = 'json';
19
+    /**
20
+     * string: json
21
+     */
22
+    const JSON = 'json';
23 23
 
24
-	/**
25
-	 * string: xml
26
-	 * NOT supported in this version
27
-	 */
28
-	const XML = 'xml';
24
+    /**
25
+     * string: xml
26
+     * NOT supported in this version
27
+     */
28
+    const XML = 'xml';
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.