@@ -25,7 +25,6 @@ |
||
25 | 25 | namespace FacebookAds\Object; |
26 | 26 | |
27 | 27 | use FacebookAds\Api; |
28 | -use FacebookAds\Cursor; |
|
29 | 28 | use FacebookAds\Http\RequestInterface; |
30 | 29 | use FacebookAds\Object\Fields\AdImageFields; |
31 | 30 | use FacebookAds\Object\Traits\CannotUpdate; |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | use FacebookAds\Object\Traits\CannotUpdate; |
32 | 32 | use FacebookAds\Object\Traits\FieldValidation; |
33 | 33 | |
34 | -class AdImage extends AbstractCrudObject |
|
35 | -{ |
|
34 | +class AdImage extends AbstractCrudObject { |
|
36 | 35 | use FieldValidation; |
37 | 36 | use CannotUpdate; |
38 | 37 | |
@@ -46,8 +45,7 @@ discard block |
||
46 | 45 | * @return array |
47 | 46 | */ |
48 | 47 | public static function createFromZip( |
49 | - $file_path, $account_id, array $params = array(), Api $api = null) |
|
50 | - { |
|
48 | + $file_path, $account_id, array $params = array(), Api $api = null) { |
|
51 | 49 | $image = new AdImage(null, $account_id, $api); |
52 | 50 | $image->{AdImageFields::FILENAME} = $file_path; |
53 | 51 | return $image->arrayFromZip($params); |
@@ -56,24 +54,21 @@ discard block |
||
56 | 54 | /** |
57 | 55 | * @return string |
58 | 56 | */ |
59 | - protected function getEndpoint() |
|
60 | - { |
|
57 | + protected function getEndpoint() { |
|
61 | 58 | return 'adimages'; |
62 | 59 | } |
63 | 60 | |
64 | 61 | /** |
65 | 62 | * @return AdImageFields |
66 | 63 | */ |
67 | - public static function getFieldsEnum() |
|
68 | - { |
|
64 | + public static function getFieldsEnum() { |
|
69 | 65 | return AdImageFields::getInstance(); |
70 | 66 | } |
71 | 67 | |
72 | 68 | /** |
73 | 69 | * @return string |
74 | 70 | */ |
75 | - protected function getNodePath() |
|
76 | - { |
|
71 | + protected function getNodePath() { |
|
77 | 72 | return '/'.$this->assureParentId().'/'.$this->getEndpoint(); |
78 | 73 | } |
79 | 74 | |
@@ -85,8 +80,7 @@ discard block |
||
85 | 80 | * @throws \Exception |
86 | 81 | * @throws \RuntimeException |
87 | 82 | */ |
88 | - public function create(array $params = array()) |
|
89 | - { |
|
83 | + public function create(array $params = array()) { |
|
90 | 84 | if ($this->data[static::FIELD_ID]) { |
91 | 85 | throw new \Exception("Object has already an ID"); |
92 | 86 | } |
@@ -129,8 +123,7 @@ discard block |
||
129 | 123 | * @param array $params Additional request parameters |
130 | 124 | * @return $this |
131 | 125 | */ |
132 | - public function read(array $fields = array(), array $params = array()) |
|
133 | - { |
|
126 | + public function read(array $fields = array(), array $params = array()) { |
|
134 | 127 | $fields = implode(',', $fields ?: static::getDefaultReadFields()); |
135 | 128 | if ($fields) { |
136 | 129 | $params['fields'] = $fields; |
@@ -159,8 +152,7 @@ discard block |
||
159 | 152 | * @return void |
160 | 153 | * @throws \Exception |
161 | 154 | */ |
162 | - public function delete(array $params = array()) |
|
163 | - { |
|
155 | + public function delete(array $params = array()) { |
|
164 | 156 | if (!$this->data[AdImageFields::HASH]) { |
165 | 157 | throw new \Exception("AdImage hash is required to delete"); |
166 | 158 | } |
@@ -178,8 +170,7 @@ discard block |
||
178 | 170 | * @return array |
179 | 171 | * @throws \RuntimeException |
180 | 172 | */ |
181 | - protected function arrayFromZip($params = array()) |
|
182 | - { |
|
173 | + protected function arrayFromZip($params = array()) { |
|
183 | 174 | if (!$this->isZipFile($this->data[AdImageFields::FILENAME])) { |
184 | 175 | throw new \RuntimeException( |
185 | 176 | $this->data[AdImageFields::FILENAME]." doesn't resolve to a zip file"); |
@@ -220,8 +211,7 @@ discard block |
||
220 | 211 | * @param string $file_path |
221 | 212 | * @return bool |
222 | 213 | */ |
223 | - protected function isZipFile($file_path) |
|
224 | - { |
|
214 | + protected function isZipFile($file_path) { |
|
225 | 215 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
226 | 216 | $file_mime_type = finfo_file($finfo, $file_path); |
227 | 217 | return $file_mime_type == 'application/zip' || |
@@ -26,8 +26,6 @@ |
||
26 | 26 | |
27 | 27 | use FacebookAds\Http\RequestInterface; |
28 | 28 | use FacebookAds\Object\Fields\AdVideoFields; |
29 | -use FacebookAds\Object\Traits\CannotDelete; |
|
30 | -use FacebookAds\Object\Traits\CannotUpdate; |
|
31 | 29 | use FacebookAds\Object\Traits\FieldValidation; |
32 | 30 | |
33 | 31 | class AdVideo extends AbstractCrudObject { |
@@ -30,28 +30,24 @@ discard block |
||
30 | 30 | use FacebookAds\Object\Traits\CannotUpdate; |
31 | 31 | use FacebookAds\Object\Traits\FieldValidation; |
32 | 32 | |
33 | -class AdVideo extends AbstractCrudObject |
|
34 | -{ |
|
33 | +class AdVideo extends AbstractCrudObject { |
|
35 | 34 | use FieldValidation; |
36 | 35 | |
37 | 36 | /** |
38 | 37 | * @return string |
39 | 38 | */ |
40 | - protected function getEndpoint() |
|
41 | - { |
|
39 | + protected function getEndpoint() { |
|
42 | 40 | return 'advideos'; |
43 | 41 | } |
44 | 42 | |
45 | 43 | /** |
46 | 44 | * @return AdVideoFields |
47 | 45 | */ |
48 | - public static function getFieldsEnum() |
|
49 | - { |
|
46 | + public static function getFieldsEnum() { |
|
50 | 47 | return AdVideoFields::getInstance(); |
51 | 48 | } |
52 | 49 | |
53 | - public function create(array $params = array()) |
|
54 | - { |
|
50 | + public function create(array $params = array()) { |
|
55 | 51 | $data = $this->exportData(); |
56 | 52 | $source = null; |
57 | 53 | if (array_key_exists(AdVideoFields::SOURCE, $data)) { |
@@ -85,8 +81,7 @@ discard block |
||
85 | 81 | * @return Cursor |
86 | 82 | */ |
87 | 83 | public function getVideoThumbnails( |
88 | - array $fields = array(), array $params = array()) |
|
89 | - { |
|
84 | + array $fields = array(), array $params = array()) { |
|
90 | 85 | return $this->getManyByConnection( |
91 | 86 | VideoThumbnail::className(), $fields, $params, 'thumbnails'); |
92 | 87 | } |
@@ -24,7 +24,6 @@ |
||
24 | 24 | |
25 | 25 | namespace FacebookAds\Object; |
26 | 26 | |
27 | -use FacebookAds\Api; |
|
28 | 27 | use FacebookAds\Object\Fields\ProductCatalogFields; |
29 | 28 | use FacebookAds\Object\Traits\FieldValidation; |
30 | 29 | use FacebookAds\Http\RequestInterface; |
@@ -30,23 +30,20 @@ discard block |
||
30 | 30 | use FacebookAds\Object\Fields\ProductCatalogFields; |
31 | 31 | use FacebookAds\Object\Traits\FieldValidation; |
32 | 32 | |
33 | -class ProductCatalog extends AbstractCrudObject |
|
34 | -{ |
|
33 | +class ProductCatalog extends AbstractCrudObject { |
|
35 | 34 | use FieldValidation; |
36 | 35 | |
37 | 36 | /** |
38 | 37 | * @return string |
39 | 38 | */ |
40 | - protected function getEndpoint() |
|
41 | - { |
|
39 | + protected function getEndpoint() { |
|
42 | 40 | return 'product_catalogs'; |
43 | 41 | } |
44 | 42 | |
45 | 43 | /** |
46 | 44 | * @return ProductCatalogFields |
47 | 45 | */ |
48 | - public static function getFieldsEnum() |
|
49 | - { |
|
46 | + public static function getFieldsEnum() { |
|
50 | 47 | return ProductCatalogFields::getInstance(); |
51 | 48 | } |
52 | 49 | |
@@ -56,8 +53,7 @@ discard block |
||
56 | 53 | * @return Cursor |
57 | 54 | */ |
58 | 55 | public function getProducts( |
59 | - array $fields = array(), array $params = array()) |
|
60 | - { |
|
56 | + array $fields = array(), array $params = array()) { |
|
61 | 57 | return $this->getManyByConnection( |
62 | 58 | Product::className(), $fields, $params); |
63 | 59 | } |
@@ -68,8 +64,7 @@ discard block |
||
68 | 64 | * @return Cursor |
69 | 65 | */ |
70 | 66 | public function getProductSets( |
71 | - array $fields = array(), array $params = array()) |
|
72 | - { |
|
67 | + array $fields = array(), array $params = array()) { |
|
73 | 68 | return $this->getManyByConnection( |
74 | 69 | ProductSet::className(), $fields, $params); |
75 | 70 | } |
@@ -80,8 +75,7 @@ discard block |
||
80 | 75 | * @return Cursor |
81 | 76 | */ |
82 | 77 | public function getProductFeeds( |
83 | - array $fields = array(), array $params = array()) |
|
84 | - { |
|
78 | + array $fields = array(), array $params = array()) { |
|
85 | 79 | return $this->getManyByConnection( |
86 | 80 | ProductFeed::className(), $fields, $params); |
87 | 81 | } |
@@ -89,8 +83,7 @@ discard block |
||
89 | 83 | /** |
90 | 84 | * @return array |
91 | 85 | */ |
92 | - public function getExternalEventSources() |
|
93 | - { |
|
86 | + public function getExternalEventSources() { |
|
94 | 87 | $response = $this->getApi()->call( |
95 | 88 | '/'.$this->assureId().'/external_event_sources', |
96 | 89 | RequestInterface::METHOD_GET); |
@@ -102,8 +95,7 @@ discard block |
||
102 | 95 | * @param array $pixel_ids |
103 | 96 | * @return bool |
104 | 97 | */ |
105 | - public function setExternalEventSources(array $pixel_ids) |
|
106 | - { |
|
98 | + public function setExternalEventSources(array $pixel_ids) { |
|
107 | 99 | return $this->modifyExternalEventSources( |
108 | 100 | RequestInterface::METHOD_POST, |
109 | 101 | $pixel_ids); |
@@ -113,8 +105,7 @@ discard block |
||
113 | 105 | * @param array $pixel_ids |
114 | 106 | * @return bool |
115 | 107 | */ |
116 | - public function removeExternalEventSources(array $pixel_ids) |
|
117 | - { |
|
108 | + public function removeExternalEventSources(array $pixel_ids) { |
|
118 | 109 | return $this->modifyExternalEventSources( |
119 | 110 | RequestInterface::METHOD_DELETE, |
120 | 111 | $pixel_ids); |
@@ -125,8 +116,7 @@ discard block |
||
125 | 116 | * @param array $pixel_ids |
126 | 117 | * @return bool |
127 | 118 | */ |
128 | - protected function modifyExternalEventSources($method, array $pixel_ids) |
|
129 | - { |
|
119 | + protected function modifyExternalEventSources($method, array $pixel_ids) { |
|
130 | 120 | $params = array( |
131 | 121 | ProductCatalogFields::EXTERNAL_EVENT_SOURCES => $pixel_ids, |
132 | 122 | ); |
@@ -143,8 +133,7 @@ discard block |
||
143 | 133 | * @param int $user_id |
144 | 134 | * @param string $role |
145 | 135 | */ |
146 | - public function addUserPermission($user_id, $role) |
|
147 | - { |
|
136 | + public function addUserPermission($user_id, $role) { |
|
148 | 137 | $params = array( |
149 | 138 | 'user' => $user_id, |
150 | 139 | 'role' => $role, |
@@ -158,8 +147,7 @@ discard block |
||
158 | 147 | /** |
159 | 148 | * @param int $user_id |
160 | 149 | */ |
161 | - public function deleteUserPermission($user_id) |
|
162 | - { |
|
150 | + public function deleteUserPermission($user_id) { |
|
163 | 151 | $params = array( |
164 | 152 | 'user' => $user_id, |
165 | 153 | ); |
@@ -25,7 +25,6 @@ |
||
25 | 25 | namespace FacebookAds\Object; |
26 | 26 | |
27 | 27 | use FacebookAds\Object\Fields\ProductFeedUploadFields; |
28 | -use FacebookAds\Object\Traits\CannotCreate; |
|
29 | 28 | use FacebookAds\Object\Traits\CannotDelete; |
30 | 29 | use FacebookAds\Object\Traits\CannotUpdate; |
31 | 30 | use FacebookAds\Cursor; |
@@ -30,24 +30,21 @@ discard block |
||
30 | 30 | use FacebookAds\Object\Traits\CannotDelete; |
31 | 31 | use FacebookAds\Object\Traits\CannotUpdate; |
32 | 32 | |
33 | -class ProductFeedUpload extends AbstractCrudObject |
|
34 | -{ |
|
33 | +class ProductFeedUpload extends AbstractCrudObject { |
|
35 | 34 | use CannotDelete; |
36 | 35 | use CannotUpdate; |
37 | 36 | |
38 | 37 | /** |
39 | 38 | * @return string |
40 | 39 | */ |
41 | - protected function getEndpoint() |
|
42 | - { |
|
40 | + protected function getEndpoint() { |
|
43 | 41 | return 'uploads'; |
44 | 42 | } |
45 | 43 | |
46 | 44 | /** |
47 | 45 | * @return ProductFeedUploadFields |
48 | 46 | */ |
49 | - public static function getFieldsEnum() |
|
50 | - { |
|
47 | + public static function getFieldsEnum() { |
|
51 | 48 | return ProductFeedUploadFields::getInstance(); |
52 | 49 | } |
53 | 50 | |
@@ -56,8 +53,7 @@ discard block |
||
56 | 53 | * @param array $params |
57 | 54 | * @return Cursor |
58 | 55 | */ |
59 | - public function getErrors(array $fields = array(), array $params = array()) |
|
60 | - { |
|
56 | + public function getErrors(array $fields = array(), array $params = array()) { |
|
61 | 57 | return $this->getManyByConnection( |
62 | 58 | ProductFeedUploadError::className(), $fields, $params); |
63 | 59 | } |
@@ -27,8 +27,6 @@ |
||
27 | 27 | use FacebookAds\Http\RequestInterface; |
28 | 28 | use FacebookAds\Object\CustomAudienceNormalizers\HashNormalizer; |
29 | 29 | use FacebookAds\Object\Fields\CustomAudienceFields; |
30 | -use FacebookAds\Object\Fields\CustomAudienceMultikeySchemaFields; |
|
31 | -use FacebookAds\Object\Values\CustomAudienceTypes; |
|
32 | 30 | |
33 | 31 | class CustomAudienceMultiKey extends AbstractCrudObject |
34 | 32 | { |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | use FacebookAds\Object\Fields\CustomAudienceMultikeySchemaFields; |
31 | 31 | use FacebookAds\Object\Values\CustomAudienceTypes; |
32 | 32 | |
33 | -class CustomAudienceMultiKey extends AbstractCrudObject |
|
34 | -{ |
|
33 | +class CustomAudienceMultiKey extends AbstractCrudObject { |
|
35 | 34 | /** |
36 | 35 | * @var string |
37 | 36 | */ |
@@ -45,24 +44,21 @@ discard block |
||
45 | 44 | /** |
46 | 45 | * @return string |
47 | 46 | */ |
48 | - protected function getEndpoint() |
|
49 | - { |
|
47 | + protected function getEndpoint() { |
|
50 | 48 | return 'customaudiences'; |
51 | 49 | } |
52 | 50 | |
53 | 51 | /** |
54 | 52 | * @return CustomAudienceFields |
55 | 53 | */ |
56 | - public static function getFieldsEnum() |
|
57 | - { |
|
54 | + public static function getFieldsEnum() { |
|
58 | 55 | return CustomAudienceFields::getInstance(); |
59 | 56 | } |
60 | 57 | |
61 | 58 | /** |
62 | 59 | * @return \ArrayObject |
63 | 60 | */ |
64 | - public function getNormalizers() |
|
65 | - { |
|
61 | + public function getNormalizers() { |
|
66 | 62 | if ($this->normalizers === null) { |
67 | 63 | $this->normalizers = new \ArrayObject(array( |
68 | 64 | new CustomAudienceNormalizers\EmailNormalizer(), |
@@ -24,6 +24,5 @@ |
||
24 | 24 | |
25 | 25 | namespace FacebookAds\Object; |
26 | 26 | |
27 | -class BusinessAdAccount extends AbstractObject |
|
28 | -{ |
|
27 | +class BusinessAdAccount extends AbstractObject { |
|
29 | 28 | } |
@@ -29,8 +29,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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( |
@@ -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 | } |
@@ -29,8 +29,7 @@ |
||
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'; |