@@ -16,14 +16,14 @@ |
||
16 | 16 | "platform" => "web", |
17 | 17 | "status" => "active", |
18 | 18 | "web_snippet" => array( |
19 | - "enable_force_variation" => false, |
|
20 | - "exclude_disabled_experiments" => false, |
|
21 | - "exclude_names" => true, |
|
22 | - "include_jquery" => true, |
|
23 | - "ip_anonymization" => false, |
|
24 | - "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
25 | - "library" => "jquery-1.11.3-trim", |
|
26 | - "project_javascript" => "alert(\"Active Experiment\")" |
|
19 | + "enable_force_variation" => false, |
|
20 | + "exclude_disabled_experiments" => false, |
|
21 | + "exclude_names" => true, |
|
22 | + "include_jquery" => true, |
|
23 | + "ip_anonymization" => false, |
|
24 | + "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
25 | + "library" => "jquery-1.11.3-trim", |
|
26 | + "project_javascript" => "alert(\"Active Experiment\")" |
|
27 | 27 | )); |
28 | 28 | |
29 | 29 | $result = new Result($data, 200); |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | * @return Result |
38 | 38 | * @throws Exception |
39 | 39 | */ |
40 | - public function listAll($projectId, $page=1, $perPage=25) |
|
40 | + public function listAll($projectId, $page = 1, $perPage = 25) |
|
41 | 41 | { |
42 | 42 | if (!is_int($projectId)) { |
43 | 43 | throw new Exception("Integer project ID expected, while got '$projectId'"); |
44 | 44 | } |
45 | 45 | |
46 | - if ($projectId<0) { |
|
46 | + if ($projectId < 0) { |
|
47 | 47 | throw new Exception("Expected positive integer project ID"); |
48 | 48 | } |
49 | 49 | |
50 | - if ($page<0) { |
|
50 | + if ($page < 0) { |
|
51 | 51 | throw new Exception('Invalid page number passed'); |
52 | 52 | } |
53 | 53 | |
54 | - if ($perPage<0 || $perPage>100) { |
|
54 | + if ($perPage < 0 || $perPage > 100) { |
|
55 | 55 | throw new Exception('Invalid page size passed'); |
56 | 56 | } |
57 | 57 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | Exception::CODE_INVALID_ARG); |
108 | 108 | } |
109 | 109 | |
110 | - if ($campaignId<0) { |
|
110 | + if ($campaignId < 0) { |
|
111 | 111 | throw new Exception("Expected positive integer campaign ID", |
112 | 112 | Exception::CODE_INVALID_ARG); |
113 | 113 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | /** |
96 | 96 | * Get campaign results |
97 | 97 | * @param integer $campaignId The id for the campaign you want results for |
98 | - * @param string $starTime The earliest time to count events in results. Defaults to the time that the campaign was first activated. |
|
98 | + * @param string $startTime The earliest time to count events in results. Defaults to the time that the campaign was first activated. |
|
99 | 99 | * @param string $endTime The latest time to count events in results. Defaults to the time the campaign was last active or the current time if the campaign is still running. |
100 | 100 | * @return Result |
101 | 101 | * @throws Exception |
@@ -36,13 +36,13 @@ |
||
36 | 36 | * @return Result |
37 | 37 | * @throws Exception |
38 | 38 | */ |
39 | - public function listAll($projectId, $page=1, $perPage=25) |
|
39 | + public function listAll($projectId, $page = 1, $perPage = 25) |
|
40 | 40 | { |
41 | - if ($page<0) { |
|
41 | + if ($page < 0) { |
|
42 | 42 | throw new Exception('Invalid page number passed'); |
43 | 43 | } |
44 | 44 | |
45 | - if ($perPage<0 || $perPage>100) { |
|
45 | + if ($perPage < 0 || $perPage > 100) { |
|
46 | 46 | throw new Exception('Invalid page size passed'); |
47 | 47 | } |
48 | 48 |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | * @return Result |
40 | 40 | * @throws Exception |
41 | 41 | */ |
42 | - public function listAll($projectId, $campaignId=null, $includeClassic=false, $page=1, $perPage=25) |
|
42 | + public function listAll($projectId, $campaignId = null, $includeClassic = false, $page = 1, $perPage = 25) |
|
43 | 43 | { |
44 | - if ($projectId==null && $campaignId==null) { |
|
44 | + if ($projectId == null && $campaignId == null) { |
|
45 | 45 | throw new Exception('Project ID or Campaign ID must be non-null'); |
46 | 46 | } |
47 | 47 | |
48 | - if ($page<0) { |
|
48 | + if ($page < 0) { |
|
49 | 49 | throw new Exception('Invalid page number passed'); |
50 | 50 | } |
51 | 51 | |
52 | - if ($perPage<0 || $perPage>100) { |
|
52 | + if ($perPage < 0 || $perPage > 100) { |
|
53 | 53 | throw new Exception('Invalid page size passed'); |
54 | 54 | } |
55 | 55 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | Exception::CODE_INVALID_ARG); |
86 | 86 | } |
87 | 87 | |
88 | - if ($experimentId<0) { |
|
88 | + if ($experimentId < 0) { |
|
89 | 89 | throw new Exception("A positive experiment ID expected"); |
90 | 90 | } |
91 | 91 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | throw new Exception("Expected argument of type Experiment"); |
176 | 176 | } |
177 | 177 | |
178 | - if ($experimentId<0) { |
|
178 | + if ($experimentId < 0) { |
|
179 | 179 | throw new Exception("Expected positive experiment ID argument"); |
180 | 180 | } |
181 | 181 |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | use WebMarketingROI\OptimizelyPHP\Exception; |
17 | 17 | |
18 | 18 | // Init class autloading. |
19 | -include dirname(__FILE__) . '/../../vendor/autoload.php'; |
|
19 | +include dirname(__FILE__).'/../../vendor/autoload.php'; |
|
20 | 20 | |
21 | 21 | // Include Utils.php - a file containing helper functions |
22 | -include dirname(__FILE__) . '/../Utils.php'; |
|
22 | +include dirname(__FILE__).'/../Utils.php'; |
|
23 | 23 | |
24 | 24 | // Read project ID from command line. |
25 | -if ($argc!=2) { |
|
26 | - die('Expected 1 command-line argument, while got ' . $argc-1); |
|
25 | +if ($argc != 2) { |
|
26 | + die('Expected 1 command-line argument, while got '.$argc - 1); |
|
27 | 27 | } |
28 | 28 | $projectId = $argv[1]; |
29 | 29 | |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | $experiments = $result->getPayload(); |
48 | 48 | |
49 | 49 | foreach ($experiments as $experiment) { |
50 | - echo "Name: " . $experiment->getName() . "\n"; |
|
51 | - echo "Description: " . $experiment->getDescription() . "\n"; |
|
52 | - echo "Status: " . $experiment->getStatus() . "\n"; |
|
53 | - echo "Created: " . $experiment->getCreated() . "\n"; |
|
50 | + echo "Name: ".$experiment->getName()."\n"; |
|
51 | + echo "Description: ".$experiment->getDescription()."\n"; |
|
52 | + echo "Status: ".$experiment->getStatus()."\n"; |
|
53 | + echo "Created: ".$experiment->getCreated()."\n"; |
|
54 | 54 | |
55 | 55 | echo "\n"; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Determine if there are more projects. |
59 | - if ($result->getNextPage()==null) |
|
59 | + if ($result->getNextPage() == null) |
|
60 | 60 | break; |
61 | 61 | |
62 | 62 | // Increment page counter. |
63 | - $page ++; |
|
63 | + $page++; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } catch (Exception $e) { |
@@ -74,6 +74,6 @@ discard block |
||
74 | 74 | |
75 | 75 | // Save access token for later use |
76 | 76 | $accessToken = $optimizelyClient->getAccessToken(); |
77 | -file_put_contents(dirname(__FILE__) . '/../access_token.json', json_encode($accessToken)); |
|
77 | +file_put_contents(dirname(__FILE__).'/../access_token.json', json_encode($accessToken)); |
|
78 | 78 | |
79 | 79 | echo "Done!\n"; |
@@ -55,8 +55,9 @@ |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | // Determine if there are more projects. |
58 | - if ($result->getNextPage()==null) |
|
59 | - break; |
|
58 | + if ($result->getNextPage()==null) { |
|
59 | + break; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | // Increment page counter. |
62 | 63 | $page ++; |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | "category" => "add_to_cart", |
25 | 25 | "description" => "Item added to cart", |
26 | 26 | "event_filter" => array( |
27 | - "filter_type" => "target_selector", |
|
28 | - "selector" => ".menu-options" |
|
27 | + "filter_type" => "target_selector", |
|
28 | + "selector" => ".menu-options" |
|
29 | 29 | ), |
30 | 30 | "event_type" => "custom", |
31 | 31 | "key" => "add_to_cart", |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | "category" => "add_to_cart", |
65 | 65 | "description" => "Item added to cart", |
66 | 66 | "event_filter" => array( |
67 | - "filter_type" => "target_selector", |
|
68 | - "selector" => ".menu-options" |
|
67 | + "filter_type" => "target_selector", |
|
68 | + "selector" => ".menu-options" |
|
69 | 69 | ), |
70 | 70 | "event_type" => "custom", |
71 | 71 | "key" => "add_to_cart", |
@@ -98,22 +98,22 @@ discard block |
||
98 | 98 | ->getMock(); |
99 | 99 | |
100 | 100 | $result = new Result(array( |
101 | - "event_filter" => array( |
|
101 | + "event_filter" => array( |
|
102 | 102 | "filter_type" => "target_selector", |
103 | 103 | "selector" => ".menu-options" |
104 | - ), |
|
105 | - "name" => "Add to Cart", |
|
106 | - "archived" => true, |
|
107 | - "category" => "add_to_cart", |
|
108 | - "description" => "string", |
|
109 | - "event_type" => "click", |
|
110 | - "key" => "add_to_cart", |
|
111 | - "created" => "2016-10-18T05:07:04.153Z", |
|
112 | - "id" => 0, |
|
113 | - "is_classic" => false, |
|
114 | - "is_editable" => true, |
|
115 | - "page_id" => 0, |
|
116 | - "project_id" => 1000 |
|
104 | + ), |
|
105 | + "name" => "Add to Cart", |
|
106 | + "archived" => true, |
|
107 | + "category" => "add_to_cart", |
|
108 | + "description" => "string", |
|
109 | + "event_type" => "click", |
|
110 | + "key" => "add_to_cart", |
|
111 | + "created" => "2016-10-18T05:07:04.153Z", |
|
112 | + "id" => 0, |
|
113 | + "is_classic" => false, |
|
114 | + "is_editable" => true, |
|
115 | + "page_id" => 0, |
|
116 | + "project_id" => 1000 |
|
117 | 117 | ), 201); |
118 | 118 | |
119 | 119 | $optimizelyApiClientMock->method('sendApiRequest') |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | $eventsService = new Events($optimizelyApiClientMock); |
123 | 123 | |
124 | 124 | $event = new ClickEvent(array( |
125 | - "event_filter" => array( |
|
125 | + "event_filter" => array( |
|
126 | 126 | "filter_type" => "target_selector", |
127 | 127 | "selector" => ".menu-options" |
128 | - ), |
|
129 | - "name" => "Add to Cart", |
|
130 | - "archived" => true, |
|
131 | - "category" => "add_to_cart", |
|
132 | - "description" => "string", |
|
133 | - "event_type" => "click", |
|
134 | - "key" => "add_to_cart" |
|
128 | + ), |
|
129 | + "name" => "Add to Cart", |
|
130 | + "archived" => true, |
|
131 | + "category" => "add_to_cart", |
|
132 | + "description" => "string", |
|
133 | + "event_type" => "click", |
|
134 | + "key" => "add_to_cart" |
|
135 | 135 | )); |
136 | 136 | |
137 | 137 | $result = $eventsService->createClickEvent(0, $event); |
@@ -192,22 +192,22 @@ discard block |
||
192 | 192 | ->getMock(); |
193 | 193 | |
194 | 194 | $result = new Result(array( |
195 | - "event_filter" => array( |
|
195 | + "event_filter" => array( |
|
196 | 196 | "filter_type" => "target_selector", |
197 | 197 | "selector" => ".menu-options" |
198 | - ), |
|
199 | - "name" => "Add to Cart", |
|
200 | - "archived" => true, |
|
201 | - "category" => "add_to_cart", |
|
202 | - "description" => "string", |
|
203 | - "event_type" => "click", |
|
204 | - "key" => "add_to_cart", |
|
205 | - "created" => "2016-10-18T05:07:04.153Z", |
|
206 | - "id" => 0, |
|
207 | - "is_classic" => false, |
|
208 | - "is_editable" => true, |
|
209 | - "page_id" => 0, |
|
210 | - "project_id" => 1000 |
|
198 | + ), |
|
199 | + "name" => "Add to Cart", |
|
200 | + "archived" => true, |
|
201 | + "category" => "add_to_cart", |
|
202 | + "description" => "string", |
|
203 | + "event_type" => "click", |
|
204 | + "key" => "add_to_cart", |
|
205 | + "created" => "2016-10-18T05:07:04.153Z", |
|
206 | + "id" => 0, |
|
207 | + "is_classic" => false, |
|
208 | + "is_editable" => true, |
|
209 | + "page_id" => 0, |
|
210 | + "project_id" => 1000 |
|
211 | 211 | ), 200); |
212 | 212 | |
213 | 213 | $optimizelyApiClientMock->method('sendApiRequest') |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | $eventsService = new Events($optimizelyApiClientMock); |
217 | 217 | |
218 | 218 | $event = new ClickEvent(array( |
219 | - "event_filter" => array( |
|
219 | + "event_filter" => array( |
|
220 | 220 | "filter_type" => "target_selector", |
221 | 221 | "selector" => ".menu-options" |
222 | - ), |
|
223 | - "name" => "Add to Cart", |
|
224 | - "archived" => true, |
|
225 | - "category" => "add_to_cart", |
|
226 | - "description" => "string", |
|
227 | - "event_type" => "click", |
|
228 | - "key" => "add_to_cart" |
|
222 | + ), |
|
223 | + "name" => "Add to Cart", |
|
224 | + "archived" => true, |
|
225 | + "category" => "add_to_cart", |
|
226 | + "description" => "string", |
|
227 | + "event_type" => "click", |
|
228 | + "key" => "add_to_cart" |
|
229 | 229 | )); |
230 | 230 | |
231 | 231 | $result = $eventsService->updateClickEvent(0, 0, $event); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | $result = $eventsService->listAll(1000, true); |
48 | 48 | $events = $result->getPayload(); |
49 | 49 | |
50 | - $this->assertTrue(count($events)==1); |
|
50 | + $this->assertTrue(count($events) == 1); |
|
51 | 51 | $this->assertTrue($events[0] instanceOf Event); |
52 | - $this->assertTrue($events[0]->getName()=='Add to Cart'); |
|
52 | + $this->assertTrue($events[0]->getName() == 'Add to Cart'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | public function testGet() |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $event = $result->getPayload(); |
88 | 88 | |
89 | 89 | $this->assertTrue($event instanceOf Event); |
90 | - $this->assertTrue($event->getName()=='Add to Cart'); |
|
90 | + $this->assertTrue($event->getName() == 'Add to Cart'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function testCreateClickEvent() |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $createdEvent = $result->getPayload(); |
139 | 139 | |
140 | 140 | $this->assertTrue($createdEvent instanceOf ClickEvent); |
141 | - $this->assertTrue($createdEvent->getName()=='Add to Cart'); |
|
141 | + $this->assertTrue($createdEvent->getName() == 'Add to Cart'); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | public function testCreateCustomEvent() |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $createdEvent = $result->getPayload(); |
182 | 182 | |
183 | 183 | $this->assertTrue($createdEvent instanceOf CustomEvent); |
184 | - $this->assertTrue($createdEvent->getName()=='Loaded New App'); |
|
184 | + $this->assertTrue($createdEvent->getName() == 'Loaded New App'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | public function testUpdateClickEvent() |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $updatedEvent = $result->getPayload(); |
233 | 233 | |
234 | 234 | $this->assertTrue($updatedEvent instanceOf ClickEvent); |
235 | - $this->assertTrue($updatedEvent->getName()=='Add to Cart'); |
|
235 | + $this->assertTrue($updatedEvent->getName() == 'Add to Cart'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | public function testUpdateCustomEvent() |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $updatedEvent = $result->getPayload(); |
276 | 276 | |
277 | 277 | $this->assertTrue($updatedEvent instanceOf CustomEvent); |
278 | - $this->assertTrue($updatedEvent->getName()=='Loaded New App'); |
|
278 | + $this->assertTrue($updatedEvent->getName() == 'Loaded New App'); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | * @return Result |
36 | 36 | * @throws Exception |
37 | 37 | */ |
38 | - public function listAll($page=1, $perPage=25) |
|
38 | + public function listAll($page = 1, $perPage = 25) |
|
39 | 39 | { |
40 | - if ($page<0) { |
|
40 | + if ($page < 0) { |
|
41 | 41 | throw new Exception('Invalid page number passed'); |
42 | 42 | } |
43 | 43 | |
44 | - if ($perPage<0 || $perPage>100) { |
|
44 | + if ($perPage < 0 || $perPage > 100) { |
|
45 | 45 | throw new Exception('Invalid page size passed'); |
46 | 46 | } |
47 | 47 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get($projectId) |
71 | 71 | { |
72 | - $projectId = (string)$projectId; |
|
72 | + $projectId = (string) $projectId; |
|
73 | 73 | |
74 | 74 | if (!preg_match('/^\d+$/', $projectId)) { |
75 | 75 | throw new Exception("A positive integer project ID expected, while got $projectId"); |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function update($projectId, $project) |
116 | 116 | { |
117 | - $projectId = (string)$projectId; |
|
117 | + $projectId = (string) $projectId; |
|
118 | 118 | |
119 | 119 | if (!preg_match('/\d+/', $projectId)) { |
120 | 120 | throw new Exception("A positive integer project ID expected, while got $projectId"); |
121 | 121 | } |
122 | 122 | |
123 | - if ($projectId<0) { |
|
123 | + if ($projectId < 0) { |
|
124 | 124 | throw new Exception("A positive project ID expected"); |
125 | 125 | } |
126 | 126 |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | case 'last_modified': $this->setLastModified($value); break; |
123 | 123 | case 'socket_token': $this->setSocketToken($value); break; |
124 | 124 | default: |
125 | - throw new Exception('Unknown option: ' . $name); |
|
125 | + throw new Exception('Unknown option: '.$name); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'platform' => $this->getPlatform(), |
141 | 141 | 'sdks' => $this->getSdks(), |
142 | 142 | 'status' => $this->getStatus(), |
143 | - 'web_snippet' => $this->getWebSnippet()?$this->getWebSnippet()->toArray():null, |
|
143 | + 'web_snippet' => $this->getWebSnippet() ? $this->getWebSnippet()->toArray() : null, |
|
144 | 144 | 'created' => $this->getCreated(), |
145 | 145 | 'id' => $this->getId(), |
146 | 146 | 'is_classic' => $this->getIsClassic(), |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | // Remove options with empty values |
152 | 152 | $cleanedOptions = array(); |
153 | 153 | foreach ($options as $name=>$value) { |
154 | - if ($value!==null) |
|
154 | + if ($value !== null) |
|
155 | 155 | $cleanedOptions[$name] = $value; |
156 | 156 | } |
157 | 157 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | case 'id': $this->setId($value); break; |
85 | 85 | case 'last_modified': $this->setLastModified($value); break; |
86 | 86 | default: |
87 | - throw new Exception('Unknown option: ' . $name); |
|
87 | + throw new Exception('Unknown option: '.$name); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | // Remove options with empty values |
110 | 110 | $cleanedOptions = array(); |
111 | 111 | foreach ($options as $name=>$value) { |
112 | - if ($value!==null) |
|
112 | + if ($value !== null) |
|
113 | 113 | $cleanedOptions[$name] = $value; |
114 | 114 | } |
115 | 115 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |