@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | public function validate() |
| 72 | 72 | { |
| 73 | 73 | if (empty($this->type)) { |
| 74 | - throw new LPTrackerSDKException('Detail type can not be null: ' . $this->__toString()); |
|
| 74 | + throw new LPTrackerSDKException('Detail type can not be null: '.$this->__toString()); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if (!in_array($this->type, self::getAllTypes(), true)) { |
|
| 78 | - throw new LPTrackerSDKException('Detail type not in (' . implode(',', self::getAllTypes()) . '): ' . $this->__toString()); |
|
| 77 | + if ( ! in_array($this->type, self::getAllTypes(), true)) { |
|
| 78 | + throw new LPTrackerSDKException('Detail type not in ('.implode(',', self::getAllTypes()).'): '.$this->__toString()); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | if (empty($this->data)) { |
| 82 | - throw new LPTrackerSDKException('Detail data can not be null: ' . $this->__toString()); |
|
| 82 | + throw new LPTrackerSDKException('Detail data can not be null: '.$this->__toString()); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return true; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | 'data' => $this->data, |
| 96 | 96 | ]; |
| 97 | 97 | |
| 98 | - if (!empty($this->id)) { |
|
| 98 | + if ( ! empty($this->id)) { |
|
| 99 | 99 | $result['id'] = $this->getId(); |
| 100 | 100 | } |
| 101 | 101 | return $result; |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function __construct(array $commentData = []) |
| 30 | 30 | { |
| 31 | - if (!empty($commentData['id'])) { |
|
| 31 | + if ( ! empty($commentData['id'])) { |
|
| 32 | 32 | $this->id = (int) $commentData['id']; |
| 33 | 33 | } |
| 34 | - if (!empty($commentData['text'])) { |
|
| 34 | + if ( ! empty($commentData['text'])) { |
|
| 35 | 35 | $this->text = $commentData['text']; |
| 36 | 36 | } |
| 37 | - if (!empty($commentData['author'])) { |
|
| 37 | + if ( ! empty($commentData['author'])) { |
|
| 38 | 38 | if ($commentData['author']['type'] === 'main') { |
| 39 | 39 | $this->ownerId = 0; |
| 40 | 40 | } else { |
| 41 | 41 | $this->ownerId = (int) $commentData['author']['id']; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | - if (!empty($commentData['created_at'])) { |
|
| 44 | + if ( ! empty($commentData['created_at'])) { |
|
| 45 | 45 | $this->setCreatedAt($commentData['created_at']); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function setCreatedAt($createdAt) |
| 122 | 122 | { |
| 123 | - if (!$createdAt instanceof \DateTime) { |
|
| 123 | + if ( ! $createdAt instanceof \DateTime) { |
|
| 124 | 124 | $createdAt = \DateTime::createFromFormat('d.m.Y H:i:s', $createdAt); |
| 125 | 125 | } |
| 126 | 126 | $this->createdAt = $createdAt; |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function __construct(array $paymentData = []) |
| 25 | 25 | { |
| 26 | - if (!empty($paymentData['category'])) { |
|
| 26 | + if ( ! empty($paymentData['category'])) { |
|
| 27 | 27 | $this->category = $paymentData['category']; |
| 28 | 28 | } |
| 29 | - if (!empty($paymentData['purpose'])) { |
|
| 29 | + if ( ! empty($paymentData['purpose'])) { |
|
| 30 | 30 | $this->purpose = $paymentData['purpose']; |
| 31 | 31 | } |
| 32 | - if (!empty($paymentData['sum'])) { |
|
| 32 | + if ( ! empty($paymentData['sum'])) { |
|
| 33 | 33 | $this->sum = $paymentData['sum']; |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | public function toArray() |
| 41 | 41 | { |
| 42 | 42 | $result = []; |
| 43 | - if (!empty($this->category)) { |
|
| 43 | + if ( ! empty($this->category)) { |
|
| 44 | 44 | $result['category'] = $this->getCategory(); |
| 45 | 45 | } |
| 46 | - if (!empty($this->purpose)) { |
|
| 46 | + if ( ! empty($this->purpose)) { |
|
| 47 | 47 | $result['purpose'] = $this->getPurpose(); |
| 48 | 48 | } |
| 49 | - if (!empty($this->sum)) { |
|
| 49 | + if ( ! empty($this->sum)) { |
|
| 50 | 50 | $result['sum'] = $this->getSum(); |
| 51 | 51 | } |
| 52 | 52 | return $result; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | throw new LPTrackerSDKException('Payment purpose is required'); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if (!isset($this->sum)) { |
|
| 69 | + if ( ! isset($this->sum)) { |
|
| 70 | 70 | throw new LPTrackerSDKException('Payment sum is required'); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -43,29 +43,29 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function __construct(array $contactData = []) |
| 45 | 45 | { |
| 46 | - if (!empty($contactData['id'])) { |
|
| 46 | + if ( ! empty($contactData['id'])) { |
|
| 47 | 47 | $this->id = (int) $contactData['id']; |
| 48 | 48 | } |
| 49 | - if (!empty($contactData['project_id'])) { |
|
| 49 | + if ( ! empty($contactData['project_id'])) { |
|
| 50 | 50 | $this->projectId = (int) $contactData['project_id']; |
| 51 | 51 | } |
| 52 | - if (!empty($contactData['name'])) { |
|
| 52 | + if ( ! empty($contactData['name'])) { |
|
| 53 | 53 | $this->name = $contactData['name']; |
| 54 | 54 | } |
| 55 | - if (!empty($contactData['profession'])) { |
|
| 55 | + if ( ! empty($contactData['profession'])) { |
|
| 56 | 56 | $this->profession = $contactData['profession']; |
| 57 | 57 | } |
| 58 | - if (!empty($contactData['site'])) { |
|
| 58 | + if ( ! empty($contactData['site'])) { |
|
| 59 | 59 | $this->site = $contactData['site']; |
| 60 | 60 | } |
| 61 | - if (!empty($contactData['details']) && is_array($contactData['details'])) { |
|
| 61 | + if ( ! empty($contactData['details']) && is_array($contactData['details'])) { |
|
| 62 | 62 | foreach ($contactData['details'] as $detail) { |
| 63 | 63 | $detail['contact_id'] = $this->id; |
| 64 | 64 | $detailModel = new ContactDetail($detail); |
| 65 | 65 | $this->addDetail($detailModel); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | - if (!empty($contactData['fields']) && is_array($contactData['fields'])) { |
|
| 68 | + if ( ! empty($contactData['fields']) && is_array($contactData['fields'])) { |
|
| 69 | 69 | foreach ($contactData['fields'] as $fieldData) { |
| 70 | 70 | $fieldData['contact_id'] = $this->id; |
| 71 | 71 | $fieldModel = new ContactField($fieldData); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | foreach ($this->details as $detail) { |
| 92 | - if (!$detail->validate()) { |
|
| 92 | + if ( ! $detail->validate()) { |
|
| 93 | 93 | throw new LPTrackerSDKException('The contact does not have valid detail'); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | 'project_id' => $this->getProjectId(), |
| 106 | 106 | 'details' => [], |
| 107 | 107 | ]; |
| 108 | - if (!empty($this->id)) { |
|
| 108 | + if ( ! empty($this->id)) { |
|
| 109 | 109 | $result['id'] = $this->getId(); |
| 110 | 110 | } |
| 111 | - if (!empty($this->name)) { |
|
| 111 | + if ( ! empty($this->name)) { |
|
| 112 | 112 | $result['name'] = $this->getName(); |
| 113 | 113 | } |
| 114 | - if (!empty($this->profession)) { |
|
| 114 | + if ( ! empty($this->profession)) { |
|
| 115 | 115 | $result['profession'] = $this->getProfession(); |
| 116 | 116 | } |
| 117 | - if (!empty($this->site)) { |
|
| 117 | + if ( ! empty($this->site)) { |
|
| 118 | 118 | $result['site'] = $this->getSite(); |
| 119 | 119 | } |
| 120 | 120 | foreach ($this->getDetails() as $detail) { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | if (empty($baseUrl)) { |
| 31 | 31 | $baseUrl = LPTrackerBase::DEFAULT_ADDRESS; |
| 32 | 32 | } |
| 33 | - $url = $baseUrl . $actionUrl; |
|
| 33 | + $url = $baseUrl.$actionUrl; |
|
| 34 | 34 | $curl = new cURL(); |
| 35 | 35 | $request = $curl->newRequest($method, $url, $data, Request::ENCODING_JSON); |
| 36 | 36 | $request->setHeader('Content-Type', 'application/json'); |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | throw new LPTrackerServerException('Can`t decode response'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (!empty($body['errors'])) { |
|
| 51 | - if (!empty($body['errors'][0]['message'])) { |
|
| 50 | + if ( ! empty($body['errors'])) { |
|
| 51 | + if ( ! empty($body['errors'][0]['message'])) { |
|
| 52 | 52 | throw new LPTrackerResponseException($body['errors'][0]['message']); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -81,13 +81,13 @@ |
||
| 81 | 81 | if (empty($config['token'])) { |
| 82 | 82 | if (empty($config['login'])) { |
| 83 | 83 | throw new LPTrackerSDKException( |
| 84 | - 'Required "login" key not supplied in config and could not find fallback environment variable "' . static::LOGIN_ENV_NAME . '"' |
|
| 84 | + 'Required "login" key not supplied in config and could not find fallback environment variable "'.static::LOGIN_ENV_NAME.'"' |
|
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | if (empty($config['password'])) { |
| 89 | 89 | throw new LPTrackerSDKException( |
| 90 | - 'Required "password" key not supplied in config and could not find fallback environment variable "' . static::PASSWORD_ENV_NAME . '"' |
|
| 90 | + 'Required "password" key not supplied in config and could not find fallback environment variable "'.static::PASSWORD_ENV_NAME.'"' |
|
| 91 | 91 | ); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function __construct(array $fileData = []) |
| 30 | 30 | { |
| 31 | - if (!empty($fileData['id'])) { |
|
| 31 | + if ( ! empty($fileData['id'])) { |
|
| 32 | 32 | $this->id = (int) $fileData['id']; |
| 33 | 33 | } |
| 34 | - if (!empty($fileData['name'])) { |
|
| 34 | + if ( ! empty($fileData['name'])) { |
|
| 35 | 35 | $this->name = $fileData['name']; |
| 36 | 36 | } |
| 37 | - if (!empty($fileData['ext'])) { |
|
| 37 | + if ( ! empty($fileData['ext'])) { |
|
| 38 | 38 | $this->ext = $fileData['ext']; |
| 39 | 39 | } |
| 40 | - if (!empty($fileData['data'])) { |
|
| 40 | + if ( ! empty($fileData['data'])) { |
|
| 41 | 41 | $this->data = $fileData['data']; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -48,16 +48,16 @@ discard block |
||
| 48 | 48 | public function toArray() |
| 49 | 49 | { |
| 50 | 50 | $result = []; |
| 51 | - if (!empty($this->id)) { |
|
| 51 | + if ( ! empty($this->id)) { |
|
| 52 | 52 | $result['id'] = $this->getId(); |
| 53 | 53 | } |
| 54 | - if (!empty($this->name)) { |
|
| 54 | + if ( ! empty($this->name)) { |
|
| 55 | 55 | $result['name'] = $this->getName(); |
| 56 | 56 | } |
| 57 | - if (!empty($this->ext)) { |
|
| 57 | + if ( ! empty($this->ext)) { |
|
| 58 | 58 | $result['ext'] = $this->getExt(); |
| 59 | 59 | } |
| 60 | - if (!empty($this->data)) { |
|
| 60 | + if ( ! empty($this->data)) { |
|
| 61 | 61 | $result['data'] = $this->getData(); |
| 62 | 62 | } |
| 63 | 63 | return $result; |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function saveFile($path) |
| 104 | 104 | { |
| 105 | - try{ |
|
| 105 | + try { |
|
| 106 | 106 | $content = $this->getData(); |
| 107 | - if(!empty($content)){ |
|
| 107 | + if ( ! empty($content)) { |
|
| 108 | 108 | @file_put_contents($path, base64_decode($content)); |
| 109 | 109 | } |
| 110 | - }catch(\Exception $e){} |
|
| 110 | + } catch (\Exception $e) {} |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function validate(){ |
|
| 113 | + public function validate() { |
|
| 114 | 114 | return true; |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -107,7 +107,7 @@ |
||
| 107 | 107 | if(!empty($content)){ |
| 108 | 108 | @file_put_contents($path, base64_decode($content)); |
| 109 | 109 | } |
| 110 | - }catch(\Exception $e){} |
|
| 110 | + } catch(\Exception $e){} |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function validate(){ |
@@ -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 | |
@@ -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) { |
@@ -458,11 +458,11 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | public function saveContactField(ContactField $field) |
| 460 | 460 | { |
| 461 | - if (!$field->validate() || empty($field->getContactId())) { |
|
| 461 | + if ( ! $field->validate() || empty($field->getContactId())) { |
|
| 462 | 462 | throw new LPTrackerSDKException('Invalid field'); |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - $url = '/contact/' . $field->getContactId() . '/field/' . $field->getId(); |
|
| 465 | + $url = '/contact/'.$field->getContactId().'/field/'.$field->getId(); |
|
| 466 | 466 | if ($field->getValue() === null) { |
| 467 | 467 | LPTrackerRequest::sendRequest($url, [], 'DELETE', $this->token, $this->address); |
| 468 | 468 | $response = $field->toArray(); |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | $viewData['project_id'] = (int) $project; |
| 491 | 491 | } |
| 492 | 492 | $view = new View($viewData); |
| 493 | - if (!$view->validate()) { |
|
| 493 | + if ( ! $view->validate()) { |
|
| 494 | 494 | throw new LPTrackerSDKException('Invalid view data'); |
| 495 | 495 | } |
| 496 | 496 | |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | throw new LPTrackerSDKException('Invalid view ID'); |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $url = '/view/' . $view; |
|
| 518 | + $url = '/view/'.$view; |
|
| 519 | 519 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
| 520 | 520 | return new View($response); |
| 521 | 521 | } |
@@ -527,12 +527,12 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | public function saveView(View $view) |
| 529 | 529 | { |
| 530 | - if (!$view->validate()) { |
|
| 530 | + if ( ! $view->validate()) { |
|
| 531 | 531 | throw new LPTrackerSDKException('Invalid view'); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | if ($view->getId() > 0) { |
| 535 | - $url = '/view/' . $view->getId(); |
|
| 535 | + $url = '/view/'.$view->getId(); |
|
| 536 | 536 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
| 537 | 537 | } else { |
| 538 | 538 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | $leadData['contact_id'] = (int) $contact; |
| 574 | 574 | } |
| 575 | 575 | $lead = new Lead($leadData); |
| 576 | - if (!$lead->validate()) { |
|
| 576 | + if ( ! $lead->validate()) { |
|
| 577 | 577 | throw new LPTrackerSDKException('Invalid lead data'); |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - if (!empty($lead->getView()) && empty($lead->getView()->getId())) { |
|
| 580 | + if ( ! empty($lead->getView()) && empty($lead->getView()->getId())) { |
|
| 581 | 581 | $contactModel = $this->getContact($contact); |
| 582 | 582 | $viewData = $lead->getView()->toArray(); |
| 583 | 583 | $lead->setView($this->createView($contactModel->getProjectId(), $viewData)); |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | } |
| 589 | 589 | if (isset($leadData['view_id'])) { |
| 590 | 590 | $data['view_id'] = (int) $leadData['view_id']; |
| 591 | - } elseif (!empty($lead->getView()) && !empty($lead->getView()->getId())) { |
|
| 591 | + } elseif ( ! empty($lead->getView()) && ! empty($lead->getView()->getId())) { |
|
| 592 | 592 | $data['view_id'] = $lead->getView()->getId(); |
| 593 | 593 | } |
| 594 | 594 | $response = LPTrackerRequest::sendRequest('/lead', $data, 'POST', $this->token, $this->address); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | throw new LPTrackerSDKException('Invalid lead ID'); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - $url = '/lead/' . $lead; |
|
| 614 | + $url = '/lead/'.$lead; |
|
| 615 | 615 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
| 616 | 616 | return new Lead($response); |
| 617 | 617 | } |
@@ -640,12 +640,12 @@ discard block |
||
| 640 | 640 | if ($custom <= 0) { |
| 641 | 641 | throw new LPTrackerSDKException('Invalid custom ID'); |
| 642 | 642 | } |
| 643 | - $file = (int)$file; |
|
| 643 | + $file = (int) $file; |
|
| 644 | 644 | if ($file <= 0) { |
| 645 | 645 | throw new LPTrackerSDKException('Invalid file ID'); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - $url = '/lead/' . $lead . '/custom/' . $custom . '/file/' . $file; |
|
| 648 | + $url = '/lead/'.$lead.'/custom/'.$custom.'/file/'.$file; |
|
| 649 | 649 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
| 650 | 650 | return new LeadFile($response); |
| 651 | 651 | } |
@@ -657,12 +657,12 @@ discard block |
||
| 657 | 657 | */ |
| 658 | 658 | public function saveLead(Lead $lead) |
| 659 | 659 | { |
| 660 | - if (!$lead->validate()) { |
|
| 660 | + if ( ! $lead->validate()) { |
|
| 661 | 661 | throw new LPTrackerSDKException('Invalid lead'); |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | if ($lead->getId() > 0) { |
| 665 | - $url = '/lead/' . $lead->getId(); |
|
| 665 | + $url = '/lead/'.$lead->getId(); |
|
| 666 | 666 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
| 667 | 667 | } else { |
| 668 | 668 | $response = LPTrackerRequest::sendRequest( |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | throw new LPTrackerSDKException('Invalid lead ID'); |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - $url = '/lead/' . $lead . '/payment'; |
|
| 729 | + $url = '/lead/'.$lead.'/payment'; |
|
| 730 | 730 | $data = [ |
| 731 | 731 | 'category' => $category, |
| 732 | 732 | 'purpose' => $purpose, |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | } else { |
| 765 | 765 | $lead = (int) $lead; |
| 766 | 766 | } |
| 767 | - $url = '/lead/' . $lead . '/funnel'; |
|
| 767 | + $url = '/lead/'.$lead.'/funnel'; |
|
| 768 | 768 | $data = [ |
| 769 | 769 | 'funnel' => $newStageId, |
| 770 | 770 | 'options' => $options, |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | } else { |
| 800 | 800 | $lead = (int) $lead; |
| 801 | 801 | } |
| 802 | - $url = '/lead/' . $lead . '/owner'; |
|
| 802 | + $url = '/lead/'.$lead.'/owner'; |
|
| 803 | 803 | $data = [ |
| 804 | 804 | 'owner' => $newOwnerId, |
| 805 | 805 | 'options' => $options, |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | } else { |
| 822 | 822 | $lead = (int) $lead; |
| 823 | 823 | } |
| 824 | - $url = '/lead/' . $lead . '/comments'; |
|
| 824 | + $url = '/lead/'.$lead.'/comments'; |
|
| 825 | 825 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
| 826 | 826 | $result = []; |
| 827 | 827 | foreach ($response as $commentData) { |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | } else { |
| 846 | 846 | $lead = (int) $lead; |
| 847 | 847 | } |
| 848 | - $url = '/lead/' . $lead . '/comment'; |
|
| 848 | + $url = '/lead/'.$lead.'/comment'; |
|
| 849 | 849 | $data = [ |
| 850 | 850 | 'text' => $text, |
| 851 | 851 | 'options' => $options, |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | } else { |
| 874 | 874 | $custom = (int) $custom; |
| 875 | 875 | } |
| 876 | - $url = '/lead/' . $lead . '/file'; |
|
| 876 | + $url = '/lead/'.$lead.'/file'; |
|
| 877 | 877 | $data = [ |
| 878 | 878 | 'name' => pathinfo($absolutePath, PATHINFO_BASENAME), |
| 879 | 879 | 'mime' => mime_content_type($absolutePath), |
@@ -890,11 +890,11 @@ discard block |
||
| 890 | 890 | */ |
| 891 | 891 | public function saveLeadCustom(Custom $custom, array $options = []) |
| 892 | 892 | { |
| 893 | - if (!$custom->validate() || empty($custom->getLeadId())) { |
|
| 893 | + if ( ! $custom->validate() || empty($custom->getLeadId())) { |
|
| 894 | 894 | throw new LPTrackerSDKException('Invalid custom'); |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - $url = '/lead/' . $custom->getLeadId() . '/custom/' . $custom->getId(); |
|
| 897 | + $url = '/lead/'.$custom->getLeadId().'/custom/'.$custom->getId(); |
|
| 898 | 898 | if ($custom->getValue() === null) { |
| 899 | 899 | $data = [ |
| 900 | 900 | 'options' => $options, |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | } else { |
| 958 | 958 | $project = (int) $project; |
| 959 | 959 | } |
| 960 | - $actionUrl = '/custom/' . $project . '/create'; |
|
| 960 | + $actionUrl = '/custom/'.$project.'/create'; |
|
| 961 | 961 | $response = LPTrackerRequest::sendRequest($actionUrl, $options, 'POST', $this->token, $this->address); |
| 962 | 962 | return new CustomField($response); |
| 963 | 963 | } |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | } else { |
| 981 | 981 | $project = (int) $project; |
| 982 | 982 | } |
| 983 | - $actionUrl = '/lead/' . $project . '/list?' . http_build_query([ |
|
| 983 | + $actionUrl = '/lead/'.$project.'/list?'.http_build_query([ |
|
| 984 | 984 | 'offset' => $offset, |
| 985 | 985 | 'limit' => $limit, |
| 986 | 986 | 'sort' => $sort, |