Failed Conditions
Pull Request — master (#191)
by Emanuele
03:09
created
src/FacebookAds/Object/BusinessAdAccount.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,6 +24,5 @@
 block discarded – undo
24 24
 
25 25
 namespace FacebookAds\Object;
26 26
 
27
-class BusinessAdAccount extends AbstractObject
28
-{
27
+class BusinessAdAccount extends AbstractObject {
29 28
 }
Please login to merge, or discard this patch.
src/FacebookAds/Object/AbstractCrudObject.php 1 patch
Braces   +25 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
 use FacebookAds\Http\RequestInterface;
30 30
 use FacebookAds\Http\ResponseInterface;
31 31
 
32
-abstract class AbstractCrudObject extends AbstractObject
33
-{
32
+abstract class AbstractCrudObject extends AbstractObject {
34 33
     /**
35 34
      * @var string
36 35
      */
@@ -61,8 +60,7 @@  discard block
 block discarded – undo
61 60
      * @param string $parent_id Optional, needed for creating new objects.
62 61
      * @param Api $api The Api instance this object should use to make calls
63 62
      */
64
-    public function __construct($id = null, $parent_id = null, Api $api = null)
65
-    {
63
+    public function __construct($id = null, $parent_id = null, Api $api = null) {
66 64
         parent::__construct();
67 65
         $this->data[static::FIELD_ID] = $id;
68 66
         $this->parentId = $parent_id;
@@ -72,24 +70,21 @@  discard block
 block discarded – undo
72 70
     /**
73 71
      * @param string $id
74 72
      */
75
-    public function setId($id)
76
-    {
73
+    public function setId($id) {
77 74
         $this->data[static::FIELD_ID] = $id;
78 75
     }
79 76
 
80 77
     /**
81 78
      * @param string $parent_id
82 79
      */
83
-    public function setParentId($parent_id)
84
-    {
80
+    public function setParentId($parent_id) {
85 81
         $this->parentId = $parent_id;
86 82
     }
87 83
 
88 84
     /**
89 85
      * @param Api $api The Api instance this object should use to make calls
90 86
      */
91
-    public function setApi(Api $api)
92
-    {
87
+    public function setApi(Api $api) {
93 88
         $this->api = static::assureApi($api);
94 89
     }
95 90
 
@@ -103,8 +98,7 @@  discard block
 block discarded – undo
103 98
      * @return Api
104 99
      * @throws \InvalidArgumentException
105 100
      */
106
-    protected static function assureApi(Api $instance = null)
107
-    {
101
+    protected static function assureApi(Api $instance = null) {
108 102
         $instance = $instance ?: Api::instance();
109 103
         if (!$instance) {
110 104
             throw new \InvalidArgumentException(
@@ -118,8 +112,7 @@  discard block
 block discarded – undo
118 112
     /**
119 113
      * @return string|null
120 114
      */
121
-    public function getParentId()
122
-    {
115
+    public function getParentId() {
123 116
         return $this->parentId;
124 117
     }
125 118
 
@@ -127,8 +120,7 @@  discard block
 block discarded – undo
127 120
      * @return string
128 121
      * @throws \Exception
129 122
      */
130
-    protected function assureParentId()
131
-    {
123
+    protected function assureParentId() {
132 124
         if (!$this->parentId) {
133 125
             throw new \Exception("A parent ID is required.");
134 126
         }
@@ -140,8 +132,7 @@  discard block
 block discarded – undo
140 132
      * @return string
141 133
      * @throws \Exception
142 134
      */
143
-    protected function assureId()
144
-    {
135
+    protected function assureId() {
145 136
         if (!$this->data[static::FIELD_ID]) {
146 137
             throw new \Exception("field '".static::FIELD_ID."' is required.");
147 138
         }
@@ -152,8 +143,7 @@  discard block
 block discarded – undo
152 143
     /**
153 144
      * @return Api
154 145
      */
155
-    public function getApi()
156
-    {
146
+    public function getApi() {
157 147
         return $this->api;
158 148
     }
159 149
 
@@ -162,8 +152,7 @@  discard block
 block discarded – undo
162 152
      *
163 153
      * @return array Key value pairs of changed variables
164 154
      */
165
-    public function getChangedValues()
166
-    {
155
+    public function getChangedValues() {
167 156
         return $this->changedFields;
168 157
     }
169 158
 
@@ -172,16 +161,14 @@  discard block
 block discarded – undo
172 161
      *
173 162
      * @return array Array of changed field names
174 163
      */
175
-    public function getChangedFields()
176
-    {
164
+    public function getChangedFields() {
177 165
         return array_keys($this->changedFields);
178 166
     }
179 167
 
180 168
     /**
181 169
      * Get the values which have changed, converting them to scalars
182 170
      */
183
-    public function exportData()
184
-    {
171
+    public function exportData() {
185 172
         $data = array();
186 173
         foreach ($this->changedFields as $key => $val) {
187 174
             $data[$key] = $val instanceof AbstractObject ? $val->exportData() : $val;
@@ -193,8 +180,7 @@  discard block
 block discarded – undo
193 180
     /**
194 181
      * @return void
195 182
      */
196
-    protected function clearHistory()
197
-    {
183
+    protected function clearHistory() {
198 184
         $this->changedFields = array();
199 185
     }
200 186
 
@@ -202,8 +188,7 @@  discard block
 block discarded – undo
202 188
      * @param string $name
203 189
      * @param mixed $value
204 190
      */
205
-    public function __set($name, $value)
206
-    {
191
+    public function __set($name, $value) {
207 192
         if (!array_key_exists($name, $this->data)
208 193
             || $this->data[$name] !== $value) {
209 194
             $this->changedFields[$name] = $value;
@@ -214,24 +199,21 @@  discard block
 block discarded – undo
214 199
     /**
215 200
      * @param string[] $fields
216 201
      */
217
-    public static function setDefaultReadFields(array $fields = array())
218
-    {
202
+    public static function setDefaultReadFields(array $fields = array()) {
219 203
         static::$defaultReadFields = $fields;
220 204
     }
221 205
 
222 206
     /**
223 207
      * @return string[]
224 208
      */
225
-    public static function getDefaultReadFields()
226
-    {
209
+    public static function getDefaultReadFields() {
227 210
         return static::$defaultReadFields;
228 211
     }
229 212
 
230 213
     /**
231 214
      * @return string
232 215
      */
233
-    protected function getNodePath()
234
-    {
216
+    protected function getNodePath() {
235 217
         return '/'.$this->assureId();
236 218
     }
237 219
 
@@ -242,8 +224,7 @@  discard block
 block discarded – undo
242 224
      * @return $this
243 225
      * @throws \Exception
244 226
      */
245
-    public function create(array $params = array())
246
-    {
227
+    public function create(array $params = array()) {
247 228
         if ($this->data[static::FIELD_ID]) {
248 229
             throw new \Exception("Object has already an ID");
249 230
         }
@@ -283,8 +264,7 @@  discard block
 block discarded – undo
283 264
      * @param array $params Additional request parameters
284 265
      * @return $this
285 266
      */
286
-    public function read(array $fields = array(), array $params = array())
287
-    {
267
+    public function read(array $fields = array(), array $params = array()) {
288 268
         $fields = implode(',', $fields ?: static::getDefaultReadFields());
289 269
         if ($fields) {
290 270
             $params['fields'] = $fields;
@@ -308,8 +288,7 @@  discard block
 block discarded – undo
308 288
      * @param array $params Update parameters in assoc
309 289
      * @return $this
310 290
      */
311
-    public function update(array $params = array())
312
-    {
291
+    public function update(array $params = array()) {
313 292
         $this->getApi()->call(
314 293
             $this->getNodePath(),
315 294
             RequestInterface::METHOD_POST,
@@ -327,8 +306,7 @@  discard block
 block discarded – undo
327 306
      * @param array $params
328 307
      * @return void
329 308
      */
330
-    public function delete(array $params = array())
331
-    {
309
+    public function delete(array $params = array()) {
332 310
         $this->getApi()->call(
333 311
             $this->getNodePath(),
334 312
             RequestInterface::METHOD_DELETE,
@@ -345,8 +323,7 @@  discard block
 block discarded – undo
345 323
      * @param array $params
346 324
      * @return $this
347 325
      */
348
-    public function save(array $params = array())
349
-    {
326
+    public function save(array $params = array()) {
350 327
         if ($this->data[static::FIELD_ID]) {
351 328
             return $this->update($params);
352 329
         } else {
@@ -360,8 +337,7 @@  discard block
 block discarded – undo
360 337
      * @return string
361 338
      * @throws \InvalidArgumentException
362 339
      */
363
-    protected function assureEndpoint($prototype_class, $endpoint)
364
-    {
340
+    protected function assureEndpoint($prototype_class, $endpoint) {
365 341
         if (!$endpoint) {
366 342
             $prototype = new $prototype_class(null, null, $this->getApi());
367 343
             if (!$prototype instanceof AbstractCrudObject) {
@@ -486,8 +462,7 @@  discard block
 block discarded – undo
486 462
      * @param Api $api Api Object to use
487 463
      * @return bool Returns true on success
488 464
      */
489
-    public static function deleteIds(array $ids, Api $api = null)
490
-    {
465
+    public static function deleteIds(array $ids, Api $api = null) {
491 466
         $batch = array();
492 467
         foreach ($ids as $id) {
493 468
             $request = array(
Please login to merge, or discard this patch.
src/FacebookAds/Object/AbstractObject.php 1 patch
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,15 +26,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/FacebookAds/Object/Search/DemographicSearchClasses.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
 /**
30 30
  * @method static DemographicSearchClasses getInstance()
31 31
  */
32
-class DemographicSearchClasses extends AbstractEnum
33
-{
32
+class DemographicSearchClasses extends AbstractEnum {
34 33
     const LIFE_EVENTS = 'life_events';
35 34
     const POLITICS = 'politics';
36 35
     const MARKETS = 'markets';
Please login to merge, or discard this patch.
src/FacebookAds/Object/Search/TargetingSearchTypes.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
 /**
30 30
  * @method static TargetingSearchTypes getInstance()
31 31
  */
32
-class TargetingSearchTypes extends AbstractEnum
33
-{
32
+class TargetingSearchTypes extends AbstractEnum {
34 33
     const COUNTRY = 'adcountry';
35 34
     const EDUCATION = 'adeducationschool';
36 35
     const EMPLOYER = 'adworkemployer';
Please login to merge, or discard this patch.
src/FacebookAds/Object/CanRedownloadInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@
 block discarded – undo
24 24
 
25 25
 namespace FacebookAds\Object;
26 26
 
27
-interface CanRedownloadInterface
28
-{
27
+interface CanRedownloadInterface {
29 28
     /**
30 29
      * @string
31 30
      */
Please login to merge, or discard this patch.
src/FacebookAds/Object/Campaign.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use FacebookAds\Object\Traits\FieldValidation;
31 31
 use FacebookAds\Object\Traits\ObjectValidation;
32 32
 
33
-class Campaign extends AbstractArchivableCrudObject
34
-{
33
+class Campaign extends AbstractArchivableCrudObject {
35 34
     use FieldValidation;
36 35
     use ObjectValidation;
37 36
     use AdLabelAwareCrudObjectTrait;
@@ -39,16 +38,14 @@  discard block
 block discarded – undo
39 38
     /**
40 39
      * @return string
41 40
      */
42
-    protected function getEndpoint()
43
-    {
41
+    protected function getEndpoint() {
44 42
         return 'campaigns';
45 43
     }
46 44
 
47 45
     /**
48 46
      * @return CampaignFields
49 47
      */
50
-    public static function getFieldsEnum()
51
-    {
48
+    public static function getFieldsEnum() {
52 49
         return CampaignFields::getInstance();
53 50
     }
54 51
 
@@ -57,8 +54,7 @@  discard block
 block discarded – undo
57 54
      * @param array $params
58 55
      * @return Cursor
59 56
      */
60
-    public function getAdSets(array $fields = array(), array $params = array())
61
-    {
57
+    public function getAdSets(array $fields = array(), array $params = array()) {
62 58
         return $this->getManyByConnection(AdSet::className(), $fields, $params);
63 59
     }
64 60
 
@@ -67,8 +63,7 @@  discard block
 block discarded – undo
67 63
      * @param array $params
68 64
      * @return Cursor
69 65
      */
70
-    public function getAds(array $fields = array(), array $params = array())
71
-    {
66
+    public function getAds(array $fields = array(), array $params = array()) {
72 67
         return $this->getManyByConnection(Ad::className(), $fields, $params);
73 68
     }
74 69
 
@@ -78,8 +73,7 @@  discard block
 block discarded – undo
78 73
      * @return Cursor
79 74
      */
80 75
     public function getInsights(
81
-        array $fields = array(), array $params = array())
82
-    {
76
+        array $fields = array(), array $params = array()) {
83 77
         return $this->getManyByConnection(
84 78
             Insights::classname(), $fields, $params, 'insights');
85 79
     }
@@ -90,8 +84,7 @@  discard block
 block discarded – undo
90 84
      * @return AsyncJobInsights
91 85
      */
92 86
     public function getInsightsAsync(
93
-        array $fields = array(), array $params = array())
94
-    {
87
+        array $fields = array(), array $params = array()) {
95 88
         return $this->createAsyncJob(
96 89
             AsyncJobInsights::className(), $fields, $params);
97 90
     }
Please login to merge, or discard this patch.
src/FacebookAds/Object/UserPermission.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,6 +24,5 @@
 block discarded – undo
24 24
 
25 25
 namespace FacebookAds\Object;
26 26
 
27
-class UserPermission extends AbstractObject
28
-{
27
+class UserPermission extends AbstractObject {
29 28
 }
Please login to merge, or discard this patch.
src/FacebookAds/Object/ProductSet.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,23 +28,20 @@  discard block
 block discarded – undo
28 28
 use FacebookAds\Object\Fields\ProductSetFields;
29 29
 use FacebookAds\Object\Traits\FieldValidation;
30 30
 
31
-class ProductSet extends AbstractCrudObject
32
-{
31
+class ProductSet extends AbstractCrudObject {
33 32
     use FieldValidation;
34 33
 
35 34
     /**
36 35
      * @return string
37 36
      */
38
-    protected function getEndpoint()
39
-    {
37
+    protected function getEndpoint() {
40 38
         return 'product_sets';
41 39
     }
42 40
 
43 41
     /**
44 42
      * @return ProductSetFields
45 43
      */
46
-    public static function getFieldsEnum()
47
-    {
44
+    public static function getFieldsEnum() {
48 45
         return ProductSetFields::getInstance();
49 46
     }
50 47
 
@@ -54,8 +51,7 @@  discard block
 block discarded – undo
54 51
      * @return Cursor
55 52
      */
56 53
     public function getProducts(
57
-        array $fields = array(), array $params = array())
58
-    {
54
+        array $fields = array(), array $params = array()) {
59 55
         return $this->getManyByConnection(
60 56
             Product::className(), $fields, $params);
61 57
     }
@@ -66,8 +62,7 @@  discard block
 block discarded – undo
66 62
      * @return Cursor
67 63
      */
68 64
     public function getProductGroups(
69
-        array $fields = array(), array $params = array())
70
-    {
65
+        array $fields = array(), array $params = array()) {
71 66
         return $this->getManyByConnection(
72 67
             ProductGroup::className(), $fields, $params, 'product_groups');
73 68
     }
Please login to merge, or discard this patch.