@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -29,8 +29,7 @@ |
||
29 | 29 | /** |
30 | 30 | * @method static ProductFields getInstance() |
31 | 31 | */ |
32 | -class ProductFields extends AbstractEnum |
|
33 | -{ |
|
32 | +class ProductFields extends AbstractEnum { |
|
34 | 33 | const ID = 'id'; |
35 | 34 | const AGE_GROUP = 'age_group'; |
36 | 35 | const AVAILABILITY = 'availability'; |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -29,8 +29,7 @@ |
||
29 | 29 | /** |
30 | 30 | * @method static AdsPixelStatFields getInstance() |
31 | 31 | */ |
32 | -class AdsPixelStatFields extends AbstractEnum |
|
33 | -{ |
|
32 | +class AdsPixelStatFields extends AbstractEnum { |
|
34 | 33 | const AGGREGATION = 'aggregation'; |
35 | 34 | const DATA = 'data'; |
36 | 35 | const TIMESTAMP = 'timestamps'; |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | namespace FacebookAds\Enum; |
26 | 26 | |
27 | -abstract class AbstractEnum implements EnumInstanceInterface |
|
28 | -{ |
|
27 | +abstract class AbstractEnum implements EnumInstanceInterface { |
|
29 | 28 | /** |
30 | 29 | * @var array|null |
31 | 30 | */ |
@@ -54,16 +53,14 @@ discard block |
||
54 | 53 | /** |
55 | 54 | * @return string |
56 | 55 | */ |
57 | - public static function className() |
|
58 | - { |
|
56 | + public static function className() { |
|
59 | 57 | return get_called_class(); |
60 | 58 | } |
61 | 59 | |
62 | 60 | /** |
63 | 61 | * @return AbstractEnum |
64 | 62 | */ |
65 | - public static function getInstance() |
|
66 | - { |
|
63 | + public static function getInstance() { |
|
67 | 64 | $fqn = get_called_class(); |
68 | 65 | if (!array_key_exists($fqn, static::$instances)) { |
69 | 66 | static::$instances[$fqn] = new static(); |
@@ -75,8 +72,7 @@ discard block |
||
75 | 72 | /** |
76 | 73 | * @return array |
77 | 74 | */ |
78 | - public function getArrayCopy() |
|
79 | - { |
|
75 | + public function getArrayCopy() { |
|
80 | 76 | if ($this->map === null) { |
81 | 77 | $this->map = (new \ReflectionClass(get_called_class())) |
82 | 78 | ->getConstants(); |
@@ -88,8 +84,7 @@ discard block |
||
88 | 84 | /** |
89 | 85 | * @return array |
90 | 86 | */ |
91 | - public function getNames() |
|
92 | - { |
|
87 | + public function getNames() { |
|
93 | 88 | if ($this->names === null) { |
94 | 89 | $this->names = array_keys($this->getArrayCopy()); |
95 | 90 | } |
@@ -100,8 +95,7 @@ discard block |
||
100 | 95 | /** |
101 | 96 | * @return array |
102 | 97 | */ |
103 | - public function getValues() |
|
104 | - { |
|
98 | + public function getValues() { |
|
105 | 99 | if ($this->values === null) { |
106 | 100 | $this->values = array_values($this->getArrayCopy()); |
107 | 101 | } |
@@ -112,8 +106,7 @@ discard block |
||
112 | 106 | /** |
113 | 107 | * @return array |
114 | 108 | */ |
115 | - public function getValuesMap() |
|
116 | - { |
|
109 | + public function getValuesMap() { |
|
117 | 110 | if ($this->valuesMap === null) { |
118 | 111 | $this->valuesMap = array_fill_keys($this->getValues(), null); |
119 | 112 | } |
@@ -125,8 +118,7 @@ discard block |
||
125 | 118 | * @param string|int|float $name |
126 | 119 | * @return mixed |
127 | 120 | */ |
128 | - public function getValueForName($name) |
|
129 | - { |
|
121 | + public function getValueForName($name) { |
|
130 | 122 | return array_key_exists($name, $this->getArrayCopy()) |
131 | 123 | ? $this->getArrayCopy()[$name] |
132 | 124 | : null; |
@@ -137,8 +129,7 @@ discard block |
||
137 | 129 | * @return mixed |
138 | 130 | * @throws \InvalidArgumentException |
139 | 131 | */ |
140 | - public function assureValueForName($name) |
|
141 | - { |
|
132 | + public function assureValueForName($name) { |
|
142 | 133 | $value = $this->getValueForName($name); |
143 | 134 | if ($value === null) { |
144 | 135 | throw new \InvalidArgumentException('Unknown name "'.$name.'" in '.static::className()); |
@@ -151,8 +142,7 @@ discard block |
||
151 | 142 | * @param string|int|float $name |
152 | 143 | * @return bool |
153 | 144 | */ |
154 | - public function isValid($name) |
|
155 | - { |
|
145 | + public function isValid($name) { |
|
156 | 146 | return array_key_exists($name, $this->getArrayCopy()); |
157 | 147 | } |
158 | 148 | |
@@ -160,8 +150,7 @@ discard block |
||
160 | 150 | * @param string|int|float $name |
161 | 151 | * @throws \InvalidArgumentException |
162 | 152 | */ |
163 | - public function assureIsValid($name) |
|
164 | - { |
|
153 | + public function assureIsValid($name) { |
|
165 | 154 | if (!array_key_exists($name, $this->getArrayCopy())) { |
166 | 155 | throw new \InvalidArgumentException('Unknown name "'.$name.'" in '.static::className()); |
167 | 156 | } |
@@ -171,8 +160,7 @@ discard block |
||
171 | 160 | * @param string|int|float $value |
172 | 161 | * @return bool |
173 | 162 | */ |
174 | - public function isValidValue($value) |
|
175 | - { |
|
163 | + public function isValidValue($value) { |
|
176 | 164 | return array_key_exists($value, $this->getValuesMap()); |
177 | 165 | } |
178 | 166 | |
@@ -180,8 +168,7 @@ discard block |
||
180 | 168 | * @param mixed $value |
181 | 169 | * @throws \InvalidArgumentException |
182 | 170 | */ |
183 | - public function assureIsValidValue($value) |
|
184 | - { |
|
171 | + public function assureIsValidValue($value) { |
|
185 | 172 | if (!$this->isValidValue($value)) { |
186 | 173 | throw new \InvalidArgumentException('"'.$value.'", not a valid value in '.static::className()); |
187 | 174 | } |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -26,15 +26,13 @@ discard block |
||
26 | 26 | |
27 | 27 | use FacebookAds\Enum\EmptyEnum; |
28 | 28 | |
29 | -abstract class AbstractObject |
|
30 | -{ |
|
29 | +abstract class AbstractObject { |
|
31 | 30 | /** |
32 | 31 | * @var mixed[] set of key value pairs representing data |
33 | 32 | */ |
34 | 33 | protected $data = array(); |
35 | 34 | |
36 | - public function __construct() |
|
37 | - { |
|
35 | + public function __construct() { |
|
38 | 36 | $this->data = static::getFieldsEnum()->getValuesMap(); |
39 | 37 | } |
40 | 38 | |
@@ -43,8 +41,7 @@ discard block |
||
43 | 41 | * @return mixed |
44 | 42 | * @throws \InvalidArgumentException |
45 | 43 | */ |
46 | - public function __get($name) |
|
47 | - { |
|
44 | + public function __get($name) { |
|
48 | 45 | if (array_key_exists($name, $this->data)) { |
49 | 46 | return $this->data[$name]; |
50 | 47 | } else { |
@@ -56,8 +53,7 @@ discard block |
||
56 | 53 | * @param string $name |
57 | 54 | * @param mixed $value |
58 | 55 | */ |
59 | - public function __set($name, $value) |
|
60 | - { |
|
56 | + public function __set($name, $value) { |
|
61 | 57 | $this->data[$name] = $value; |
62 | 58 | } |
63 | 59 | |
@@ -65,8 +61,7 @@ discard block |
||
65 | 61 | * @param string $name |
66 | 62 | * @return boolean |
67 | 63 | */ |
68 | - public function __isset($name) |
|
69 | - { |
|
64 | + public function __isset($name) { |
|
70 | 65 | return array_key_exists($name, $this->data); |
71 | 66 | } |
72 | 67 | |
@@ -74,8 +69,7 @@ discard block |
||
74 | 69 | * @param array |
75 | 70 | * @return $this |
76 | 71 | */ |
77 | - public function setData(array $data) |
|
78 | - { |
|
72 | + public function setData(array $data) { |
|
79 | 73 | foreach ($data as $key => $value) { |
80 | 74 | $this->{$key} = $value; |
81 | 75 | } |
@@ -89,8 +83,7 @@ discard block |
||
89 | 83 | * @param array |
90 | 84 | * @return $this |
91 | 85 | */ |
92 | - public function setDataWithoutValidation(array $data) |
|
93 | - { |
|
86 | + public function setDataWithoutValidation(array $data) { |
|
94 | 87 | foreach ($data as $key => $value) { |
95 | 88 | $this->data[$key] = $value; |
96 | 89 | } |
@@ -101,8 +94,7 @@ discard block |
||
101 | 94 | /** |
102 | 95 | * @return array |
103 | 96 | */ |
104 | - public function getData() |
|
105 | - { |
|
97 | + public function getData() { |
|
106 | 98 | return $this->data; |
107 | 99 | } |
108 | 100 | |
@@ -110,8 +102,7 @@ discard block |
||
110 | 102 | * @param mixed $value |
111 | 103 | * @return mixed |
112 | 104 | */ |
113 | - protected function exportValue($value) |
|
114 | - { |
|
105 | + protected function exportValue($value) { |
|
115 | 106 | switch (true) { |
116 | 107 | case $value === null: |
117 | 108 | break; |
@@ -134,32 +125,28 @@ discard block |
||
134 | 125 | /** |
135 | 126 | * @return array |
136 | 127 | */ |
137 | - public function exportData() |
|
138 | - { |
|
128 | + public function exportData() { |
|
139 | 129 | return $this->exportValue($this->data); |
140 | 130 | } |
141 | 131 | |
142 | 132 | /** |
143 | 133 | * @return EmptyEnum |
144 | 134 | */ |
145 | - public static function getFieldsEnum() |
|
146 | - { |
|
135 | + public static function getFieldsEnum() { |
|
147 | 136 | return EmptyEnum::getInstance(); |
148 | 137 | } |
149 | 138 | |
150 | 139 | /** |
151 | 140 | * @return array |
152 | 141 | */ |
153 | - public static function getFields() |
|
154 | - { |
|
142 | + public static function getFields() { |
|
155 | 143 | return static::getFieldsEnum()->getValues(); |
156 | 144 | } |
157 | 145 | |
158 | 146 | /** |
159 | 147 | * @return string |
160 | 148 | */ |
161 | - public static function className() |
|
162 | - { |
|
149 | + public static function className() { |
|
163 | 150 | return get_called_class(); |
164 | 151 | } |
165 | 152 | } |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -29,8 +29,7 @@ |
||
29 | 29 | /** |
30 | 30 | * @method static AdLabelFields getInstance() |
31 | 31 | */ |
32 | -class AdLabelFields extends AbstractEnum |
|
33 | -{ |
|
32 | +class AdLabelFields extends AbstractEnum { |
|
34 | 33 | const ID = 'id'; |
35 | 34 | const NAME = 'name'; |
36 | 35 | } |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -29,8 +29,7 @@ |
||
29 | 29 | /** |
30 | 30 | * @method static ProductCatalogFields getInstance() |
31 | 31 | */ |
32 | -class ProductCatalogFields extends AbstractEnum |
|
33 | -{ |
|
32 | +class ProductCatalogFields extends AbstractEnum { |
|
34 | 33 | const ID = 'id'; |
35 | 34 | const BUSINESS = 'business'; |
36 | 35 | const EXTERNAL_EVENT_SOURCES = 'external_event_sources'; |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -24,6 +24,5 @@ |
||
24 | 24 | |
25 | 25 | namespace FacebookAds\Object; |
26 | 26 | |
27 | -class CreditCard extends AbstractObject |
|
28 | -{ |
|
27 | +class CreditCard extends AbstractObject { |
|
29 | 28 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * @return Api|null |
|
93 | + * @return Api |
|
94 | 94 | */ |
95 | 95 | public static function instance() |
96 | 96 | { |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | use FacebookAds\Logger\LoggerInterface; |
31 | 31 | use FacebookAds\Logger\NullLogger; |
32 | 32 | |
33 | -class Api |
|
34 | -{ |
|
33 | +class Api { |
|
35 | 34 | /** |
36 | 35 | * @var string |
37 | 36 | */ |
@@ -80,8 +79,7 @@ discard block |
||
80 | 79 | * @param string $access_token |
81 | 80 | * @return static |
82 | 81 | */ |
83 | - public static function init($app_id, $app_secret, $access_token) |
|
84 | - { |
|
82 | + public static function init($app_id, $app_secret, $access_token) { |
|
85 | 83 | $session = new Session($app_id, $app_secret, $access_token); |
86 | 84 | $api = new static(new Client(), $session); |
87 | 85 | static::setInstance($api); |
@@ -92,16 +90,14 @@ discard block |
||
92 | 90 | /** |
93 | 91 | * @return Api|null |
94 | 92 | */ |
95 | - public static function instance() |
|
96 | - { |
|
93 | + public static function instance() { |
|
97 | 94 | return static::$instance; |
98 | 95 | } |
99 | 96 | |
100 | 97 | /** |
101 | 98 | * @param Api $instance |
102 | 99 | */ |
103 | - public static function setInstance(Api $instance) |
|
104 | - { |
|
100 | + public static function setInstance(Api $instance) { |
|
105 | 101 | static::$instance = $instance; |
106 | 102 | } |
107 | 103 | |
@@ -109,8 +105,7 @@ discard block |
||
109 | 105 | * @param string $string |
110 | 106 | * @return string |
111 | 107 | */ |
112 | - public static function base64UrlEncode($string) |
|
113 | - { |
|
108 | + public static function base64UrlEncode($string) { |
|
114 | 109 | $str = strtr(base64_encode($string), '+/', '-_'); |
115 | 110 | $str = str_replace('=', '', $str); |
116 | 111 | return $str; |
@@ -151,8 +146,7 @@ discard block |
||
151 | 146 | * @param RequestInterface $request |
152 | 147 | * @return ResponseInterface |
153 | 148 | */ |
154 | - public function executeRequest(RequestInterface $request) |
|
155 | - { |
|
149 | + public function executeRequest(RequestInterface $request) { |
|
156 | 150 | $this->getLogger()->logRequest('debug', $request); |
157 | 151 | $response = $request->execute(); |
158 | 152 | $this->getLogger()->logResponse('debug', $response); |
@@ -163,8 +157,7 @@ discard block |
||
163 | 157 | /** |
164 | 158 | * @return string |
165 | 159 | */ |
166 | - public function getDefaultGraphVersion() |
|
167 | - { |
|
160 | + public function getDefaultGraphVersion() { |
|
168 | 161 | if ($this->defaultGraphVersion === null) { |
169 | 162 | $match = array(); |
170 | 163 | if (preg_match("/^\d+\.\d+/", static::VERSION, $match)) { |
@@ -178,8 +171,7 @@ discard block |
||
178 | 171 | /** |
179 | 172 | * @param string $version |
180 | 173 | */ |
181 | - public function setDefaultGraphVersion($version) |
|
182 | - { |
|
174 | + public function setDefaultGraphVersion($version) { |
|
183 | 175 | $this->defaultGraphVersion = $version; |
184 | 176 | } |
185 | 177 | |
@@ -204,24 +196,21 @@ discard block |
||
204 | 196 | /** |
205 | 197 | * @return Session |
206 | 198 | */ |
207 | - public function getSession() |
|
208 | - { |
|
199 | + public function getSession() { |
|
209 | 200 | return $this->session; |
210 | 201 | } |
211 | 202 | |
212 | 203 | /** |
213 | 204 | * @param LoggerInterface $logger |
214 | 205 | */ |
215 | - public function setLogger(LoggerInterface $logger) |
|
216 | - { |
|
206 | + public function setLogger(LoggerInterface $logger) { |
|
217 | 207 | $this->logger = $logger; |
218 | 208 | } |
219 | 209 | |
220 | 210 | /** |
221 | 211 | * @return LoggerInterface |
222 | 212 | */ |
223 | - public function getLogger() |
|
224 | - { |
|
213 | + public function getLogger() { |
|
225 | 214 | if ($this->logger === null) { |
226 | 215 | $this->logger = new NullLogger(); |
227 | 216 | } |
@@ -232,8 +221,7 @@ discard block |
||
232 | 221 | /** |
233 | 222 | * @return Client |
234 | 223 | */ |
235 | - public function getHttpClient() |
|
236 | - { |
|
224 | + public function getHttpClient() { |
|
237 | 225 | return $this->httpClient; |
238 | 226 | } |
239 | 227 | } |
@@ -499,7 +499,7 @@ |
||
499 | 499 | |
500 | 500 | /** |
501 | 501 | * @param mixed $offset |
502 | - * @return mixed |
|
502 | + * @return AbstractObject|null |
|
503 | 503 | */ |
504 | 504 | public function offsetGet($offset) |
505 | 505 | { |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | - * |
|
5 | - * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | - * use, copy, modify, and distribute this software in source code or binary |
|
7 | - * form for use in connection with the web services and APIs provided by |
|
8 | - * Facebook. |
|
9 | - * |
|
10 | - * As with any software that integrates with the Facebook platform, your use |
|
11 | - * of this software is subject to the Facebook Developer Principles and |
|
12 | - * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | - * shall be included in all copies or substantial portions of the software. |
|
14 | - * |
|
15 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | - * DEALINGS IN THE SOFTWARE. |
|
22 | - * |
|
23 | - */ |
|
3 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
4 | + * |
|
5 | + * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
|
6 | + * use, copy, modify, and distribute this software in source code or binary |
|
7 | + * form for use in connection with the web services and APIs provided by |
|
8 | + * Facebook. |
|
9 | + * |
|
10 | + * As with any software that integrates with the Facebook platform, your use |
|
11 | + * of this software is subject to the Facebook Developer Principles and |
|
12 | + * Policies [http://developers.facebook.com/policy/]. This copyright notice |
|
13 | + * shall be included in all copies or substantial portions of the software. |
|
14 | + * |
|
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
18 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
21 | + * DEALINGS IN THE SOFTWARE. |
|
22 | + * |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | namespace FacebookAds\Object\Fields; |
26 | 26 |
@@ -84,8 +84,7 @@ discard block |
||
84 | 84 | * @param array $object_data |
85 | 85 | * @return AbstractObject |
86 | 86 | */ |
87 | - protected function createObject(array $object_data) |
|
88 | - { |
|
87 | + protected function createObject(array $object_data) { |
|
89 | 88 | $object = clone $this->objectPrototype; |
90 | 89 | $object->setDataWithoutValidation($object_data); |
91 | 90 | |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | * @return array |
98 | 97 | * @throws \InvalidArgumentException |
99 | 98 | */ |
100 | - protected function assureResponseData(ResponseInterface $response) |
|
101 | - { |
|
99 | + protected function assureResponseData(ResponseInterface $response) { |
|
102 | 100 | $content = $response->getContent(); |
103 | 101 | if (!isset($content['data']) || !is_array($content['data'])) { |
104 | 102 | throw new \InvalidArgumentException("Malformed response data"); |
@@ -110,8 +108,7 @@ discard block |
||
110 | 108 | /** |
111 | 109 | * @param ResponseInterface $response |
112 | 110 | */ |
113 | - protected function prependResponse(ResponseInterface $response) |
|
114 | - { |
|
111 | + protected function prependResponse(ResponseInterface $response) { |
|
115 | 112 | $this->response = $response; |
116 | 113 | $data = $this->assureResponseData($response); |
117 | 114 | if (empty($data)) { |
@@ -130,8 +127,7 @@ discard block |
||
130 | 127 | /** |
131 | 128 | * @param ResponseInterface $response |
132 | 129 | */ |
133 | - protected function appendResponse(ResponseInterface $response) |
|
134 | - { |
|
130 | + protected function appendResponse(ResponseInterface $response) { |
|
135 | 131 | $this->response = $response; |
136 | 132 | $data = $this->assureResponseData($response); |
137 | 133 | if (empty($data)) { |
@@ -154,24 +150,21 @@ discard block |
||
154 | 150 | /** |
155 | 151 | * @return bool |
156 | 152 | */ |
157 | - public static function getDefaultUseImplicitFetch() |
|
158 | - { |
|
153 | + public static function getDefaultUseImplicitFetch() { |
|
159 | 154 | return static::$defaultUseImplicitFetch; |
160 | 155 | } |
161 | 156 | |
162 | 157 | /** |
163 | 158 | * @param bool $use_implicit_fectch |
164 | 159 | */ |
165 | - public static function setDefaultUseImplicitFetch($use_implicit_fectch) |
|
166 | - { |
|
160 | + public static function setDefaultUseImplicitFetch($use_implicit_fectch) { |
|
167 | 161 | static::$defaultUseImplicitFetch = $use_implicit_fectch; |
168 | 162 | } |
169 | 163 | |
170 | 164 | /** |
171 | 165 | * @return bool |
172 | 166 | */ |
173 | - public function getUseImplicitFetch() |
|
174 | - { |
|
167 | + public function getUseImplicitFetch() { |
|
175 | 168 | return $this->useImplicitFectch !== null |
176 | 169 | ? $this->useImplicitFectch |
177 | 170 | : static::$defaultUseImplicitFetch; |
@@ -180,16 +173,14 @@ discard block |
||
180 | 173 | /** |
181 | 174 | * @param bool $use_implicit_fectch |
182 | 175 | */ |
183 | - public function setUseImplicitFetch($use_implicit_fectch) |
|
184 | - { |
|
176 | + public function setUseImplicitFetch($use_implicit_fectch) { |
|
185 | 177 | $this->useImplicitFectch = $use_implicit_fectch; |
186 | 178 | } |
187 | 179 | |
188 | 180 | /** |
189 | 181 | * @return string|null |
190 | 182 | */ |
191 | - public function getBefore() |
|
192 | - { |
|
183 | + public function getBefore() { |
|
193 | 184 | $content = $this->getLastResponse()->getContent(); |
194 | 185 | |
195 | 186 | return isset($content['paging']['cursors']['before']) |
@@ -200,8 +191,7 @@ discard block |
||
200 | 191 | /** |
201 | 192 | * @return string|null |
202 | 193 | */ |
203 | - public function getAfter() |
|
204 | - { |
|
194 | + public function getAfter() { |
|
205 | 195 | $content = $this->getLastResponse()->getContent(); |
206 | 196 | |
207 | 197 | return isset($content['paging']['cursors']['after']) |
@@ -212,8 +202,7 @@ discard block |
||
212 | 202 | /** |
213 | 203 | * @return RequestInterface |
214 | 204 | */ |
215 | - protected function createUndirectionalizedRequest() |
|
216 | - { |
|
205 | + protected function createUndirectionalizedRequest() { |
|
217 | 206 | $request = $this->getLastResponse()->getRequest()->createClone(); |
218 | 207 | $params = $request->getQueryParams(); |
219 | 208 | if (array_key_exists('before', $params)) { |
@@ -229,8 +218,7 @@ discard block |
||
229 | 218 | /** |
230 | 219 | * @return string|null |
231 | 220 | */ |
232 | - public function getPrevious() |
|
233 | - { |
|
221 | + public function getPrevious() { |
|
234 | 222 | $content = $this->getLastResponse()->getContent(); |
235 | 223 | if (isset($content['paging']['previous'])) { |
236 | 224 | return $content['paging']['previous']; |
@@ -249,8 +237,7 @@ discard block |
||
249 | 237 | /** |
250 | 238 | * @return string|null |
251 | 239 | */ |
252 | - public function getNext() |
|
253 | - { |
|
240 | + public function getNext() { |
|
254 | 241 | $content = $this->getLastResponse()->getContent(); |
255 | 242 | if (isset($content['paging']['next'])) { |
256 | 243 | return $content['paging']['next']; |
@@ -270,8 +257,7 @@ discard block |
||
270 | 257 | * @param string $url |
271 | 258 | * @return RequestInterface |
272 | 259 | */ |
273 | - protected function createRequestFromUrl($url) |
|
274 | - { |
|
260 | + protected function createRequestFromUrl($url) { |
|
275 | 261 | $components = parse_url($url); |
276 | 262 | $request = $this->getLastResponse()->getRequest()->createClone(); |
277 | 263 | $request->setDomain($components['host']); |
@@ -286,8 +272,7 @@ discard block |
||
286 | 272 | /** |
287 | 273 | * @return RequestInterface|null |
288 | 274 | */ |
289 | - public function createBeforeRequest() |
|
290 | - { |
|
275 | + public function createBeforeRequest() { |
|
291 | 276 | $url = $this->getPrevious(); |
292 | 277 | return $url !== null ? $this->createRequestFromUrl($url) : null; |
293 | 278 | } |
@@ -295,14 +280,12 @@ discard block |
||
295 | 280 | /** |
296 | 281 | * @return RequestInterface|null |
297 | 282 | */ |
298 | - public function createAfterRequest() |
|
299 | - { |
|
283 | + public function createAfterRequest() { |
|
300 | 284 | $url = $this->getNext(); |
301 | 285 | return $url !== null ? $this->createRequestFromUrl($url) : null; |
302 | 286 | } |
303 | 287 | |
304 | - public function fetchBefore() |
|
305 | - { |
|
288 | + public function fetchBefore() { |
|
306 | 289 | $request = $this->createBeforeRequest(); |
307 | 290 | if (!$request) { |
308 | 291 | return; |
@@ -311,8 +294,7 @@ discard block |
||
311 | 294 | $this->prependResponse($request->execute()); |
312 | 295 | } |
313 | 296 | |
314 | - public function fetchAfter() |
|
315 | - { |
|
297 | + public function fetchAfter() { |
|
316 | 298 | $request = $this->createAfterRequest(); |
317 | 299 | if (!$request) { |
318 | 300 | return; |
@@ -325,8 +307,7 @@ discard block |
||
325 | 307 | * @deprecated Use getArrayCopy() |
326 | 308 | * @return AbstractObject[] |
327 | 309 | */ |
328 | - public function getObjects() |
|
329 | - { |
|
310 | + public function getObjects() { |
|
330 | 311 | return $this->objects; |
331 | 312 | } |
332 | 313 | |
@@ -334,8 +315,7 @@ discard block |
||
334 | 315 | * @param bool $ksort |
335 | 316 | * @return AbstractObject[] |
336 | 317 | */ |
337 | - public function getArrayCopy($ksort = false) |
|
338 | - { |
|
318 | + public function getArrayCopy($ksort = false) { |
|
339 | 319 | if ($ksort) { |
340 | 320 | // Sort the main array to improve best case performance in future |
341 | 321 | // invocations |
@@ -349,50 +329,43 @@ discard block |
||
349 | 329 | * @deprecated Use getLastResponse() |
350 | 330 | * @return ResponseInterface |
351 | 331 | */ |
352 | - public function getResponse() |
|
353 | - { |
|
332 | + public function getResponse() { |
|
354 | 333 | return $this->response; |
355 | 334 | } |
356 | 335 | |
357 | 336 | /** |
358 | 337 | * @return ResponseInterface |
359 | 338 | */ |
360 | - public function getLastResponse() |
|
361 | - { |
|
339 | + public function getLastResponse() { |
|
362 | 340 | return $this->response; |
363 | 341 | } |
364 | 342 | |
365 | 343 | /** |
366 | 344 | * @return int |
367 | 345 | */ |
368 | - public function getIndexLeft() |
|
369 | - { |
|
346 | + public function getIndexLeft() { |
|
370 | 347 | return $this->indexLeft; |
371 | 348 | } |
372 | 349 | |
373 | 350 | /** |
374 | 351 | * @return int |
375 | 352 | */ |
376 | - public function getIndexRight() |
|
377 | - { |
|
353 | + public function getIndexRight() { |
|
378 | 354 | return $this->indexRight; |
379 | 355 | } |
380 | 356 | |
381 | - public function rewind() |
|
382 | - { |
|
357 | + public function rewind() { |
|
383 | 358 | $this->position = $this->indexLeft; |
384 | 359 | } |
385 | 360 | |
386 | - public function end() |
|
387 | - { |
|
361 | + public function end() { |
|
388 | 362 | $this->position = $this->indexRight; |
389 | 363 | } |
390 | 364 | |
391 | 365 | /** |
392 | 366 | * @param int $position |
393 | 367 | */ |
394 | - public function seekTo($position) |
|
395 | - { |
|
368 | + public function seekTo($position) { |
|
396 | 369 | $position = array_key_exists($position, $this->objects) ? $position : null; |
397 | 370 | $this->position = $position; |
398 | 371 | } |
@@ -400,8 +373,7 @@ discard block |
||
400 | 373 | /** |
401 | 374 | * @return AbstractObject|bool |
402 | 375 | */ |
403 | - public function current() |
|
404 | - { |
|
376 | + public function current() { |
|
405 | 377 | return isset($this->objects[$this->position]) |
406 | 378 | ? $this->objects[$this->position] |
407 | 379 | : false; |
@@ -410,13 +382,11 @@ discard block |
||
410 | 382 | /** |
411 | 383 | * @return int |
412 | 384 | */ |
413 | - public function key() |
|
414 | - { |
|
385 | + public function key() { |
|
415 | 386 | return $this->position; |
416 | 387 | } |
417 | 388 | |
418 | - public function prev() |
|
419 | - { |
|
389 | + public function prev() { |
|
420 | 390 | if ($this->position == $this->getIndexLeft()) { |
421 | 391 | if ($this->getUseImplicitFetch()) { |
422 | 392 | $this->fetchBefore(); |
@@ -433,8 +403,7 @@ discard block |
||
433 | 403 | } |
434 | 404 | } |
435 | 405 | |
436 | - public function next() |
|
437 | - { |
|
406 | + public function next() { |
|
438 | 407 | if ($this->position == $this->getIndexRight()) { |
439 | 408 | if ($this->getUseImplicitFetch()) { |
440 | 409 | $this->fetchAfter(); |
@@ -454,16 +423,14 @@ discard block |
||
454 | 423 | /** |
455 | 424 | * @return bool |
456 | 425 | */ |
457 | - public function valid() |
|
458 | - { |
|
426 | + public function valid() { |
|
459 | 427 | return isset($this->objects[$this->position]); |
460 | 428 | } |
461 | 429 | |
462 | 430 | /** |
463 | 431 | * @return int |
464 | 432 | */ |
465 | - public function count() |
|
466 | - { |
|
433 | + public function count() { |
|
467 | 434 | return count($this->objects); |
468 | 435 | } |
469 | 436 | |
@@ -471,8 +438,7 @@ discard block |
||
471 | 438 | * @param mixed $offset |
472 | 439 | * @param mixed $value |
473 | 440 | */ |
474 | - public function offsetSet($offset, $value) |
|
475 | - { |
|
441 | + public function offsetSet($offset, $value) { |
|
476 | 442 | if ($offset === null) { |
477 | 443 | $this->objects[] = $value; |
478 | 444 | } else { |
@@ -484,16 +450,14 @@ discard block |
||
484 | 450 | * @param mixed $offset |
485 | 451 | * @return bool |
486 | 452 | */ |
487 | - public function offsetExists($offset) |
|
488 | - { |
|
453 | + public function offsetExists($offset) { |
|
489 | 454 | return isset($this->objects[$offset]); |
490 | 455 | } |
491 | 456 | |
492 | 457 | /** |
493 | 458 | * @param mixed $offset |
494 | 459 | */ |
495 | - public function offsetUnset($offset) |
|
496 | - { |
|
460 | + public function offsetUnset($offset) { |
|
497 | 461 | unset($this->objects[$offset]); |
498 | 462 | } |
499 | 463 | |
@@ -501,8 +465,7 @@ discard block |
||
501 | 465 | * @param mixed $offset |
502 | 466 | * @return mixed |
503 | 467 | */ |
504 | - public function offsetGet($offset) |
|
505 | - { |
|
468 | + public function offsetGet($offset) { |
|
506 | 469 | return isset($this->objects[$offset]) ? $this->objects[$offset] : null; |
507 | 470 | } |
508 | 471 | } |