@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } else { |
91 | 91 | $project = (int) $project; |
92 | 92 | } |
93 | - $url = '/project/' . $project; |
|
93 | + $url = '/project/'.$project; |
|
94 | 94 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
95 | 95 | return new Project($response); |
96 | 96 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } else { |
120 | 120 | $project = (int) $project; |
121 | 121 | } |
122 | - $url = '/project/' . $project . '/customs'; |
|
122 | + $url = '/project/'.$project.'/customs'; |
|
123 | 123 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
124 | 124 | $result = []; |
125 | 125 | foreach ($response as $customData) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } else { |
142 | 142 | $project = (int) $project; |
143 | 143 | } |
144 | - $url = '/project/' . $project . '/funnel'; |
|
144 | + $url = '/project/'.$project.'/funnel'; |
|
145 | 145 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
146 | 146 | $result = []; |
147 | 147 | foreach ($response as $stageData) { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } else { |
164 | 164 | $project = (int) $project; |
165 | 165 | } |
166 | - $url = '/project/' . $project . '/fields'; |
|
166 | + $url = '/project/'.$project.'/fields'; |
|
167 | 167 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
168 | 168 | $result = []; |
169 | 169 | foreach ($response as $customData) { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } else { |
186 | 186 | $project = (int) $project; |
187 | 187 | } |
188 | - $url = '/project/' . $project . '/callback-url'; |
|
188 | + $url = '/project/'.$project.'/callback-url'; |
|
189 | 189 | LPTrackerRequest::sendRequest($url, ['url' => $callbackUrl], 'PUT', $this->token, $this->address); |
190 | 190 | } |
191 | 191 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | throw new LPTrackerSDKException('Invalid contact ID'); |
262 | 262 | } |
263 | 263 | |
264 | - $url = '/contact/' . $contact; |
|
264 | + $url = '/contact/'.$contact; |
|
265 | 265 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
266 | 266 | return new Contact($response); |
267 | 267 | } |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function saveContact(Contact $contact) |
275 | 275 | { |
276 | - if (!$contact->validate()) { |
|
276 | + if ( ! $contact->validate()) { |
|
277 | 277 | throw new LPTrackerSDKException('Invalid contact'); |
278 | 278 | } |
279 | 279 | |
280 | 280 | $data = $contact->toArray(); |
281 | - if (!empty($data['fields'])) { |
|
281 | + if ( ! empty($data['fields'])) { |
|
282 | 282 | $fields = []; |
283 | 283 | foreach ($data['fields'] as $field) { |
284 | 284 | $fields[$field['id']] = $field['value']; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $data['fields'] = $fields; |
287 | 287 | } |
288 | 288 | if ($contact->getId() > 0) { |
289 | - $url = '/contact/' . $contact->getId(); |
|
289 | + $url = '/contact/'.$contact->getId(); |
|
290 | 290 | $response = LPTrackerRequest::sendRequest($url, $contact->toArray(), 'PUT', $this->token, $this->address); |
291 | 291 | } else { |
292 | 292 | $response = LPTrackerRequest::sendRequest('/contact', $contact->toArray(), 'POST', $this->token, $this->address); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | if (isset($searchOptions['phone'])) { |
361 | 361 | $data['phone'] = $searchOptions['phone']; |
362 | 362 | } |
363 | - $url = '/contact/search?' . http_build_query($data); |
|
363 | + $url = '/contact/search?'.http_build_query($data); |
|
364 | 364 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
365 | 365 | $result = []; |
366 | 366 | foreach ($response as $contactData) { |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | throw new LPTrackerSDKException('Invalid contact id'); |
386 | 386 | } |
387 | 387 | |
388 | - $url = '/contact/' . $contact . '/leads'; |
|
388 | + $url = '/contact/'.$contact.'/leads'; |
|
389 | 389 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
390 | 390 | $result = []; |
391 | 391 | foreach ($response as $leadData) { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | } else { |
426 | 426 | $field = (int) $field; |
427 | 427 | } |
428 | - $url = '/contact/' . $contact . '/field/' . $field; |
|
428 | + $url = '/contact/'.$contact.'/field/'.$field; |
|
429 | 429 | $data = [ |
430 | 430 | 'value' => $newValue, |
431 | 431 | ]; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $viewData['project_id'] = (int) $project; |
448 | 448 | } |
449 | 449 | $view = new View($viewData); |
450 | - if (!$view->validate()) { |
|
450 | + if ( ! $view->validate()) { |
|
451 | 451 | throw new LPTrackerSDKException('Invalid view data'); |
452 | 452 | } |
453 | 453 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | throw new LPTrackerSDKException('Invalid view ID'); |
473 | 473 | } |
474 | 474 | |
475 | - $url = '/view/' . $view; |
|
475 | + $url = '/view/'.$view; |
|
476 | 476 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
477 | 477 | return new View($response); |
478 | 478 | } |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function saveView(View $view) |
486 | 486 | { |
487 | - if (!$view->validate()) { |
|
487 | + if ( ! $view->validate()) { |
|
488 | 488 | throw new LPTrackerSDKException('Invalid view'); |
489 | 489 | } |
490 | 490 | |
491 | 491 | if ($view->getId() > 0) { |
492 | - $url = '/view/' . $view->getId(); |
|
492 | + $url = '/view/'.$view->getId(); |
|
493 | 493 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
494 | 494 | } else { |
495 | 495 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | $leadData['contact_id'] = (int) $contact; |
531 | 531 | } |
532 | 532 | $lead = new Lead($leadData); |
533 | - if (!$lead->validate()) { |
|
533 | + if ( ! $lead->validate()) { |
|
534 | 534 | throw new LPTrackerSDKException('Invalid lead data'); |
535 | 535 | } |
536 | 536 | |
537 | - if (!empty($lead->getView()) && empty($lead->getView()->getId())) { |
|
537 | + if ( ! empty($lead->getView()) && empty($lead->getView()->getId())) { |
|
538 | 538 | $contactModel = $this->getContact($contact); |
539 | 539 | $viewData = $lead->getView()->toArray(); |
540 | 540 | $lead->setView($this->createView($contactModel->getProjectId(), $viewData)); |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | } |
546 | 546 | if (isset($leadData['view_id'])) { |
547 | 547 | $data['view_id'] = (int) $leadData['view_id']; |
548 | - } elseif (!empty($lead->getView()) && !empty($lead->getView()->getId())) { |
|
548 | + } elseif ( ! empty($lead->getView()) && ! empty($lead->getView()->getId())) { |
|
549 | 549 | $data['view_id'] = $lead->getView()->getId(); |
550 | 550 | } |
551 | 551 | $response = LPTrackerRequest::sendRequest('/lead', $data, 'POST', $this->token, $this->address); |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | throw new LPTrackerSDKException('Invalid lead ID'); |
569 | 569 | } |
570 | 570 | |
571 | - $url = '/lead/' . $lead; |
|
571 | + $url = '/lead/'.$lead; |
|
572 | 572 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
573 | 573 | return new Lead($response); |
574 | 574 | } |
@@ -597,12 +597,12 @@ discard block |
||
597 | 597 | if ($custom <= 0) { |
598 | 598 | throw new LPTrackerSDKException('Invalid custom ID'); |
599 | 599 | } |
600 | - $file = (int)$file; |
|
600 | + $file = (int) $file; |
|
601 | 601 | if ($file <= 0) { |
602 | 602 | throw new LPTrackerSDKException('Invalid file ID'); |
603 | 603 | } |
604 | 604 | |
605 | - $url = '/lead/' . $lead . '/custom/' . $custom . '/file/' . $file; |
|
605 | + $url = '/lead/'.$lead.'/custom/'.$custom.'/file/'.$file; |
|
606 | 606 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
607 | 607 | return new LeadFile($response); |
608 | 608 | } |
@@ -614,12 +614,12 @@ discard block |
||
614 | 614 | */ |
615 | 615 | public function saveLead(Lead $lead) |
616 | 616 | { |
617 | - if (!$lead->validate()) { |
|
617 | + if ( ! $lead->validate()) { |
|
618 | 618 | throw new LPTrackerSDKException('Invalid lead'); |
619 | 619 | } |
620 | 620 | |
621 | 621 | if ($lead->getId() > 0) { |
622 | - $url = '/lead/' . $lead->getId(); |
|
622 | + $url = '/lead/'.$lead->getId(); |
|
623 | 623 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
624 | 624 | } else { |
625 | 625 | $response = LPTrackerRequest::sendRequest( |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | throw new LPTrackerSDKException('Invalid lead ID'); |
684 | 684 | } |
685 | 685 | |
686 | - $url = '/lead/' . $lead . '/payment'; |
|
686 | + $url = '/lead/'.$lead.'/payment'; |
|
687 | 687 | $data = [ |
688 | 688 | 'category' => $category, |
689 | 689 | 'purpose' => $purpose, |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | } else { |
722 | 722 | $lead = (int) $lead; |
723 | 723 | } |
724 | - $url = '/lead/' . $lead . '/funnel'; |
|
724 | + $url = '/lead/'.$lead.'/funnel'; |
|
725 | 725 | $data = [ |
726 | 726 | 'funnel' => $newStageId, |
727 | 727 | 'options' => $options, |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | } else { |
757 | 757 | $lead = (int) $lead; |
758 | 758 | } |
759 | - $url = '/lead/' . $lead . '/owner'; |
|
759 | + $url = '/lead/'.$lead.'/owner'; |
|
760 | 760 | $data = [ |
761 | 761 | 'owner' => $newOwnerId, |
762 | 762 | 'options' => $options, |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | } else { |
779 | 779 | $lead = (int) $lead; |
780 | 780 | } |
781 | - $url = '/lead/' . $lead . '/comments'; |
|
781 | + $url = '/lead/'.$lead.'/comments'; |
|
782 | 782 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
783 | 783 | $result = []; |
784 | 784 | foreach ($response as $commentData) { |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | } else { |
803 | 803 | $lead = (int) $lead; |
804 | 804 | } |
805 | - $url = '/lead/' . $lead . '/comment'; |
|
805 | + $url = '/lead/'.$lead.'/comment'; |
|
806 | 806 | $data = [ |
807 | 807 | 'text' => $text, |
808 | 808 | 'options' => $options, |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | } else { |
831 | 831 | $custom = (int) $custom; |
832 | 832 | } |
833 | - $url = '/lead/' . $lead . '/file'; |
|
833 | + $url = '/lead/'.$lead.'/file'; |
|
834 | 834 | $data = [ |
835 | 835 | 'name' => pathinfo($absolutePath, PATHINFO_BASENAME), |
836 | 836 | 'mime' => mime_content_type($absolutePath), |
@@ -847,11 +847,11 @@ discard block |
||
847 | 847 | */ |
848 | 848 | public function saveLeadCustom(Custom $custom, array $options = []) |
849 | 849 | { |
850 | - if (!$custom->validate() || empty($custom->getLeadId())) { |
|
850 | + if ( ! $custom->validate() || empty($custom->getLeadId())) { |
|
851 | 851 | throw new LPTrackerSDKException('Invalid custom'); |
852 | 852 | } |
853 | 853 | |
854 | - $url = '/lead/' . $custom->getLeadId() . '/custom/' . $custom->getId(); |
|
854 | + $url = '/lead/'.$custom->getLeadId().'/custom/'.$custom->getId(); |
|
855 | 855 | if ($custom->getValue() === null) { |
856 | 856 | $data = [ |
857 | 857 | 'options' => $options, |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | } else { |
913 | 913 | $project = (int) $project; |
914 | 914 | } |
915 | - $actionUrl = '/custom/' . $project . '/create'; |
|
915 | + $actionUrl = '/custom/'.$project.'/create'; |
|
916 | 916 | $response = LPTrackerRequest::sendRequest($actionUrl, $options, 'POST', $this->token, $this->address); |
917 | 917 | return new CustomField($response); |
918 | 918 | } |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | } else { |
936 | 936 | $project = (int) $project; |
937 | 937 | } |
938 | - $actionUrl = '/lead/' . $project . '/list?' . http_build_query([ |
|
938 | + $actionUrl = '/lead/'.$project.'/list?'.http_build_query([ |
|
939 | 939 | 'offset' => $offset, |
940 | 940 | 'limit' => $limit, |
941 | 941 | 'sort' => $sort, |
@@ -37,16 +37,16 @@ |
||
37 | 37 | */ |
38 | 38 | public function __construct(array $customData = [], $leadId = 0) |
39 | 39 | { |
40 | - if (!isset($customData['id'])) { |
|
40 | + if ( ! isset($customData['id'])) { |
|
41 | 41 | $this->id = (int) $customData['id']; |
42 | 42 | } |
43 | - if (!isset($customData['type'])) { |
|
43 | + if ( ! isset($customData['type'])) { |
|
44 | 44 | $this->type = $customData['type']; |
45 | 45 | } |
46 | - if (!isset($customData['name'])) { |
|
46 | + if ( ! isset($customData['name'])) { |
|
47 | 47 | $this->name = $customData['name']; |
48 | 48 | } |
49 | - if (!isset($customData['value'])) { |
|
49 | + if ( ! isset($customData['value'])) { |
|
50 | 50 | $this->value = $customData['value']; |
51 | 51 | } |
52 | 52 | if ($leadId > 0) { |
@@ -34,13 +34,13 @@ |
||
34 | 34 | if (isset($visitorData['version'])) { |
35 | 35 | $this->version = (int) $visitorData['version']; |
36 | 36 | } |
37 | - if (!empty($visitorData['fingerprint'])) { |
|
37 | + if ( ! empty($visitorData['fingerprint'])) { |
|
38 | 38 | $this->fingerprint = $visitorData['fingerprint']; |
39 | 39 | } |
40 | - if (!empty($visitorData['browser'])) { |
|
40 | + if ( ! empty($visitorData['browser'])) { |
|
41 | 41 | $this->browser = $visitorData['browser']; |
42 | 42 | } |
43 | - if (!empty($visitorData['ip'])) { |
|
43 | + if ( ! empty($visitorData['ip'])) { |
|
44 | 44 | $this->ip = $visitorData['ip']; |
45 | 45 | } |
46 | 46 | } |
@@ -58,22 +58,22 @@ discard block |
||
58 | 58 | |
59 | 59 | public function __construct(array $leadData = []) |
60 | 60 | { |
61 | - if (!empty($leadData['id'])) { |
|
61 | + if ( ! empty($leadData['id'])) { |
|
62 | 62 | $this->id = (int) $leadData['id']; |
63 | 63 | } |
64 | - if (!empty($leadData['contact_id'])) { |
|
64 | + if ( ! empty($leadData['contact_id'])) { |
|
65 | 65 | $this->contactId = (int) $leadData['contact_id']; |
66 | 66 | } |
67 | - if (!empty($leadData['name'])) { |
|
67 | + if ( ! empty($leadData['name'])) { |
|
68 | 68 | $this->name = $leadData['name']; |
69 | 69 | } |
70 | - if (!empty($leadData['funnel'])) { |
|
70 | + if ( ! empty($leadData['funnel'])) { |
|
71 | 71 | $this->funnelId = (int) $leadData['funnel']; |
72 | 72 | } |
73 | - if (!empty($leadData['stage_id'])) { |
|
73 | + if ( ! empty($leadData['stage_id'])) { |
|
74 | 74 | $this->funnelId = (int) $leadData['stage_id']; |
75 | 75 | } |
76 | - if (!empty($leadData['view'])) { |
|
76 | + if ( ! empty($leadData['view'])) { |
|
77 | 77 | $this->view = new View($leadData['view']); |
78 | 78 | } |
79 | 79 | if (isset($leadData['owner'])) { |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | if (isset($leadData['owner_id'])) { |
83 | 83 | $this->ownerId = (int) $leadData['owner_id']; |
84 | 84 | } |
85 | - if (!empty($leadData['payments']) && is_array($leadData['payments'])) { |
|
85 | + if ( ! empty($leadData['payments']) && is_array($leadData['payments'])) { |
|
86 | 86 | foreach ($leadData['payments'] as $paymentData) { |
87 | 87 | $paymentModel = new Payment($paymentData); |
88 | 88 | $this->addPayment($paymentModel); |
89 | 89 | } |
90 | 90 | } |
91 | - if (!empty($leadData['custom']) && is_array($leadData['custom'])) { |
|
91 | + if ( ! empty($leadData['custom']) && is_array($leadData['custom'])) { |
|
92 | 92 | foreach ($leadData['custom'] as $customData) { |
93 | 93 | $customModel = new Custom($customData, $this->id); |
94 | 94 | $this->addCustom($customModel); |
95 | 95 | } |
96 | 96 | } |
97 | - if (!empty($leadData['lead_date'])) { |
|
97 | + if ( ! empty($leadData['lead_date'])) { |
|
98 | 98 | $date = \DateTime::createFromFormat('d.m.Y H:i', $leadData['lead_date']); |
99 | 99 | $this->setCreatedAt($date); |
100 | 100 | } |
101 | - if (!empty($leadData['created_at'])) { |
|
101 | + if ( ! empty($leadData['created_at'])) { |
|
102 | 102 | $date = \DateTime::createFromFormat('d.m.Y H:i', $leadData['created_at']); |
103 | 103 | $this->setCreatedAt($date); |
104 | 104 | } |
105 | - if (!empty($leadData['deal_date'])) { |
|
105 | + if ( ! empty($leadData['deal_date'])) { |
|
106 | 106 | $this->options['deal_date'] = $leadData['deal_date']; |
107 | 107 | } |
108 | - if (!empty($leadData['params']) && is_array($leadData['params'])) { |
|
108 | + if ( ! empty($leadData['params']) && is_array($leadData['params'])) { |
|
109 | 109 | $this->options['params'] = $leadData['params']; |
110 | 110 | } |
111 | 111 | } |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | $result = [ |
120 | 120 | 'contact_id' => $this->contactId, |
121 | 121 | ]; |
122 | - if (!empty($this->id)) { |
|
122 | + if ( ! empty($this->id)) { |
|
123 | 123 | $result['id'] = $this->getId(); |
124 | 124 | } |
125 | - if (!empty($this->name)) { |
|
125 | + if ( ! empty($this->name)) { |
|
126 | 126 | $result['name'] = $this->getName(); |
127 | 127 | } |
128 | - if (!empty($this->funnelId)) { |
|
128 | + if ( ! empty($this->funnelId)) { |
|
129 | 129 | $result['funnel'] = $this->getFunnelId(); |
130 | 130 | $result['stage_id'] = $this->getFunnelId(); |
131 | 131 | } |
132 | - if (!empty($this->ownerId)) { |
|
132 | + if ( ! empty($this->ownerId)) { |
|
133 | 133 | $result['owner'] = $this->getOwnerId(); |
134 | 134 | $result['owner_id'] = $this->getOwnerId(); |
135 | 135 | } |
136 | - if (!empty($this->createdAt)) { |
|
136 | + if ( ! empty($this->createdAt)) { |
|
137 | 137 | $result['lead_date'] = $this->getCreatedAt()->format('d.m.Y H:i'); |
138 | 138 | } |
139 | - if (!empty($this->view)) { |
|
139 | + if ( ! empty($this->view)) { |
|
140 | 140 | $result['view'] = $this->view->toArray(); |
141 | 141 | } |
142 | 142 | foreach ($this->getPayments() as $payment) { |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | throw new LPTrackerSDKException('Invalid contact id'); |
170 | 170 | } |
171 | 171 | |
172 | - if (!empty($this->funnelId) && (int) $this->funnelId <= 0) { |
|
172 | + if ( ! empty($this->funnelId) && (int) $this->funnelId <= 0) { |
|
173 | 173 | throw new LPTrackerSDKException('Invalid funnel ID'); |
174 | 174 | } |
175 | 175 | |
176 | - if (!empty($this->ownerId) && (int) $this->ownerId < 0) { |
|
176 | + if ( ! empty($this->ownerId) && (int) $this->ownerId < 0) { |
|
177 | 177 | throw new LPTrackerSDKException('Invalid owner ID'); |
178 | 178 | } |
179 | 179 |