@@ -28,15 +28,13 @@ discard block |
||
28 | 28 | use FacebookAds\Object\CustomAudienceNormalizers\ValueNormalizerInterface; |
29 | 29 | use FacebookAds\Object\Fields\CustomAudienceMultikeySchemaFields; |
30 | 30 | |
31 | -class GenderNormalizer implements ValueNormalizerInterface |
|
32 | -{ |
|
31 | +class GenderNormalizer implements ValueNormalizerInterface { |
|
33 | 32 | /** |
34 | 33 | * @param string $key |
35 | 34 | * @param string $key_value |
36 | 35 | * @return boolean |
37 | 36 | */ |
38 | - public function shouldNormalize($key, $key_value) |
|
39 | - { |
|
37 | + public function shouldNormalize($key, $key_value) { |
|
40 | 38 | return $key === CustomAudienceMultikeySchemaFields::GENDER; |
41 | 39 | } |
42 | 40 | |
@@ -45,8 +43,7 @@ discard block |
||
45 | 43 | * @param string $key_value |
46 | 44 | * @return string |
47 | 45 | */ |
48 | - public function normalize($key, $key_value) |
|
49 | - { |
|
46 | + public function normalize($key, $key_value) { |
|
50 | 47 | return substr($key_value, 0, 1); |
51 | 48 | } |
52 | 49 | } |
@@ -28,15 +28,13 @@ discard block |
||
28 | 28 | use FacebookAds\Object\CustomAudienceNormalizers\ValueNormalizerInterface; |
29 | 29 | use FacebookAds\Object\Fields\CustomAudienceMultikeySchemaFields; |
30 | 30 | |
31 | -class EmailNormalizer implements ValueNormalizerInterface |
|
32 | -{ |
|
31 | +class EmailNormalizer implements ValueNormalizerInterface { |
|
33 | 32 | /** |
34 | 33 | * @param string $key |
35 | 34 | * @param string $key_value |
36 | 35 | * @return boolean |
37 | 36 | */ |
38 | - public function shouldNormalize($key, $key_value) |
|
39 | - { |
|
37 | + public function shouldNormalize($key, $key_value) { |
|
40 | 38 | return $key === CustomAudienceMultikeySchemaFields::EMAIL; |
41 | 39 | } |
42 | 40 | |
@@ -45,8 +43,7 @@ discard block |
||
45 | 43 | * @param string $key_value |
46 | 44 | * @return string |
47 | 45 | */ |
48 | - public function normalize($key, $key_value) |
|
49 | - { |
|
46 | + public function normalize($key, $key_value) { |
|
50 | 47 | return trim(strtolower($key_value), ' \t\r\n\0\x0B.'); |
51 | 48 | } |
52 | 49 | } |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | use FacebookAds\Http\RequestInterface; |
28 | 28 | use FacebookAds\Object\Traits\CannotUpdate; |
29 | 29 | |
30 | -abstract class AbstractAsyncJobObject extends AbstractCrudObject |
|
31 | -{ |
|
30 | +abstract class AbstractAsyncJobObject extends AbstractCrudObject { |
|
32 | 31 | use CannotUpdate; |
33 | 32 | |
34 | 33 | /** |
@@ -39,8 +38,7 @@ discard block |
||
39 | 38 | /** |
40 | 39 | * @return string |
41 | 40 | */ |
42 | - protected function getCompletitionPercentageFieldName() |
|
43 | - { |
|
41 | + protected function getCompletitionPercentageFieldName() { |
|
44 | 42 | return 'async_percent_completion'; |
45 | 43 | } |
46 | 44 | |
@@ -51,8 +49,7 @@ discard block |
||
51 | 49 | * @return $this |
52 | 50 | * @throws \Exception |
53 | 51 | */ |
54 | - public function create(array $params = array()) |
|
55 | - { |
|
52 | + public function create(array $params = array()) { |
|
56 | 53 | if ($this->data[static::FIELD_ID]) { |
57 | 54 | throw new \Exception("Object has already an ID"); |
58 | 55 | } |
@@ -73,8 +70,7 @@ discard block |
||
73 | 70 | * This method won't fetch new data, you are required to call read() before |
74 | 71 | * @return bool |
75 | 72 | */ |
76 | - public function isComplete() |
|
77 | - { |
|
73 | + public function isComplete() { |
|
78 | 74 | return $this->{$this->getCompletitionPercentageFieldName()} === 100; |
79 | 75 | } |
80 | 76 |
@@ -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; |
26 | 26 |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | use FacebookAds\Http\RequestInterface; |
28 | 28 | |
29 | -abstract class AbstractArchivableCrudObject extends AbstractCrudObject |
|
30 | -{ |
|
29 | +abstract class AbstractArchivableCrudObject extends AbstractCrudObject { |
|
31 | 30 | /** |
32 | 31 | * @var string |
33 | 32 | */ |
@@ -56,8 +55,7 @@ discard block |
||
56 | 55 | /** |
57 | 56 | * @return string |
58 | 57 | */ |
59 | - public function getStatusParamName() |
|
60 | - { |
|
58 | + public function getStatusParamName() { |
|
61 | 59 | return self::STATUS_PARAM_NAME; |
62 | 60 | } |
63 | 61 | |
@@ -67,8 +65,7 @@ discard block |
||
67 | 65 | * @param array $params |
68 | 66 | * @return void |
69 | 67 | */ |
70 | - public function archive(array $params = array()) |
|
71 | - { |
|
68 | + public function archive(array $params = array()) { |
|
72 | 69 | $this->getApi()->call( |
73 | 70 | $this->getNodePath(), |
74 | 71 | RequestInterface::METHOD_POST, |
@@ -84,8 +81,7 @@ discard block |
||
84 | 81 | * @param array $params |
85 | 82 | * @return void |
86 | 83 | */ |
87 | - public function delete(array $params = array()) |
|
88 | - { |
|
84 | + public function delete(array $params = array()) { |
|
89 | 85 | $this->getApi()->call( |
90 | 86 | $this->getNodePath(), |
91 | 87 | RequestInterface::METHOD_POST, |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | use FacebookAds\Object\Fields\CustomAudienceFields; |
31 | 31 | use FacebookAds\Object\Values\CustomAudienceTypes; |
32 | 32 | |
33 | -class CustomAudience extends AbstractCrudObject |
|
34 | -{ |
|
33 | +class CustomAudience extends AbstractCrudObject { |
|
35 | 34 | /** |
36 | 35 | * @var string |
37 | 36 | * @deprecated use HashNormalizer::HASH_TYPE_SHA256 |
@@ -41,16 +40,14 @@ discard block |
||
41 | 40 | /** |
42 | 41 | * @return string |
43 | 42 | */ |
44 | - protected function getEndpoint() |
|
45 | - { |
|
43 | + protected function getEndpoint() { |
|
46 | 44 | return 'customaudiences'; |
47 | 45 | } |
48 | 46 | |
49 | 47 | /** |
50 | 48 | * @return CustomAudienceFields |
51 | 49 | */ |
52 | - public static function getFieldsEnum() |
|
53 | - { |
|
50 | + public static function getFieldsEnum() { |
|
54 | 51 | return CustomAudienceFields::getInstance(); |
55 | 52 | } |
56 | 53 | |
@@ -182,8 +179,7 @@ discard block |
||
182 | 179 | * @param array $act_ids Array of account IDs |
183 | 180 | * @return boolean Returns true on success |
184 | 181 | */ |
185 | - public function addSharedAccounts($act_ids) |
|
186 | - { |
|
182 | + public function addSharedAccounts($act_ids) { |
|
187 | 183 | return $this->getApi()->call( |
188 | 184 | '/'.$this->assureId().'/adaccounts', |
189 | 185 | RequestInterface::METHOD_POST, |
@@ -197,8 +193,7 @@ discard block |
||
197 | 193 | * @param array $act_ids Array of Account IDs to remove |
198 | 194 | * @return boolean Returns true on success |
199 | 195 | */ |
200 | - public function removeSharedAccounts($act_ids) |
|
201 | - { |
|
196 | + public function removeSharedAccounts($act_ids) { |
|
202 | 197 | return $this->getApi()->call( |
203 | 198 | '/'.$this->assureId().'/adaccounts', |
204 | 199 | RequestInterface::METHOD_DELETE, |
@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | use FacebookAds\Object\Fields\AdAccountGroupUserFields; |
30 | 30 | use FacebookAds\Object\Traits\FieldValidation; |
31 | 31 | |
32 | -class AdAccountGroupUser extends AbstractObject |
|
33 | -{ |
|
32 | +class AdAccountGroupUser extends AbstractObject { |
|
34 | 33 | use FieldValidation; |
35 | 34 | |
36 | 35 | /** |
@@ -62,8 +61,7 @@ discard block |
||
62 | 61 | * @param string $ad_account_group_id |
63 | 62 | * @param Api $api |
64 | 63 | */ |
65 | - public function __construct($ad_account_group_id, Api $api = null) |
|
66 | - { |
|
64 | + public function __construct($ad_account_group_id, Api $api = null) { |
|
67 | 65 | $this->adAccountGroupId = $ad_account_group_id; |
68 | 66 | $this->api = $api; |
69 | 67 | } |
@@ -71,24 +69,21 @@ discard block |
||
71 | 69 | /** |
72 | 70 | * @return AdAccountGroupUserFields |
73 | 71 | */ |
74 | - public static function getFieldsEnum() |
|
75 | - { |
|
72 | + public static function getFieldsEnum() { |
|
76 | 73 | return AdAccountGroupUserFields::getInstance(); |
77 | 74 | } |
78 | 75 | |
79 | 76 | /** |
80 | 77 | * @return Api |
81 | 78 | */ |
82 | - public function getApi() |
|
83 | - { |
|
79 | + public function getApi() { |
|
84 | 80 | return $this->api; |
85 | 81 | } |
86 | 82 | |
87 | 83 | /** |
88 | 84 | * @return string |
89 | 85 | */ |
90 | - public function getParentId() |
|
91 | - { |
|
86 | + public function getParentId() { |
|
92 | 87 | return $this->adAccountGroupId; |
93 | 88 | } |
94 | 89 | |
@@ -96,8 +91,7 @@ discard block |
||
96 | 91 | * @param array $params |
97 | 92 | * @return $this |
98 | 93 | */ |
99 | - public function create(array $params = array()) |
|
100 | - { |
|
94 | + public function create(array $params = array()) { |
|
101 | 95 | return $this->save($params); |
102 | 96 | } |
103 | 97 | |
@@ -105,8 +99,7 @@ discard block |
||
105 | 99 | * @param array $params |
106 | 100 | * @return $this |
107 | 101 | */ |
108 | - public function update(array $params = array()) |
|
109 | - { |
|
102 | + public function update(array $params = array()) { |
|
110 | 103 | return $this->save($params); |
111 | 104 | } |
112 | 105 | |
@@ -114,8 +107,7 @@ discard block |
||
114 | 107 | * @return string |
115 | 108 | * @throws \Exception |
116 | 109 | */ |
117 | - protected function assureId() |
|
118 | - { |
|
110 | + protected function assureId() { |
|
119 | 111 | if (!$this->data[AdAccountGroupUserFields::UID]) { |
120 | 112 | throw new \Exception(AdAccountGroupUserFields::UID.' field must be set'); |
121 | 113 | } |
@@ -127,8 +119,7 @@ discard block |
||
127 | 119 | * @param array $params |
128 | 120 | * @return $this |
129 | 121 | */ |
130 | - public function save(array $params = array()) |
|
131 | - { |
|
122 | + public function save(array $params = array()) { |
|
132 | 123 | $this->assureId(); |
133 | 124 | |
134 | 125 | $this->getApi()->call( |
@@ -143,8 +134,7 @@ discard block |
||
143 | 134 | * @param array $params |
144 | 135 | * @throws \Exception |
145 | 136 | */ |
146 | - public function delete(array $params = array()) |
|
147 | - { |
|
137 | + public function delete(array $params = array()) { |
|
148 | 138 | if (!$this->data[AdAccountGroupUserFields::UID]) { |
149 | 139 | throw new \Exception("UID field must be set"); |
150 | 140 | } |
@@ -160,8 +150,7 @@ discard block |
||
160 | 150 | /** |
161 | 151 | * @return AdUser |
162 | 152 | */ |
163 | - public function getAdUser() |
|
164 | - { |
|
153 | + public function getAdUser() { |
|
165 | 154 | return new AdUser($this->{AdAccountGroupUserFields::UID}); |
166 | 155 | } |
167 | 156 | } |
@@ -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 | } |
@@ -24,8 +24,7 @@ |
||
24 | 24 | |
25 | 25 | namespace FacebookAds\Enum; |
26 | 26 | |
27 | -interface EnumInstanceInterface |
|
28 | -{ |
|
27 | +interface EnumInstanceInterface { |
|
29 | 28 | /** |
30 | 29 | * @return EnumInstanceInterface |
31 | 30 | */ |
@@ -24,37 +24,32 @@ |
||
24 | 24 | |
25 | 25 | namespace FacebookAds\Enum; |
26 | 26 | |
27 | -class EmptyEnum extends AbstractEnum |
|
28 | -{ |
|
27 | +class EmptyEnum extends AbstractEnum { |
|
29 | 28 | /** |
30 | 29 | * @return array |
31 | 30 | */ |
32 | - public function getArrayCopy() |
|
33 | - { |
|
31 | + public function getArrayCopy() { |
|
34 | 32 | return array(); |
35 | 33 | } |
36 | 34 | |
37 | 35 | /** |
38 | 36 | * @return array |
39 | 37 | */ |
40 | - public function getNames() |
|
41 | - { |
|
38 | + public function getNames() { |
|
42 | 39 | return array(); |
43 | 40 | } |
44 | 41 | |
45 | 42 | /** |
46 | 43 | * @return array |
47 | 44 | */ |
48 | - public function getValues() |
|
49 | - { |
|
45 | + public function getValues() { |
|
50 | 46 | return array(); |
51 | 47 | } |
52 | 48 | |
53 | 49 | /** |
54 | 50 | * @return array |
55 | 51 | */ |
56 | - public function getValuesMap() |
|
57 | - { |
|
52 | + public function getValuesMap() { |
|
58 | 53 | return array(); |
59 | 54 | } |
60 | 55 | } |