From 7372d58b8785d0bbe0f0ab84a68b34af0a10c238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ro=C3=9Fdeutscher?= Date: Tue, 8 Mar 2016 10:05:17 +0100 Subject: [PATCH] adding fluent interface to models --- .../CloseIoApiWrapper/Model/Address.php | 49 +++++-- .../CloseIoApiWrapper/Model/Contact.php | 61 ++++++-- .../CloseIoApiWrapper/Model/Email.php | 22 +-- .../CloseIoApiWrapper/Model/Lead.php | 128 +++++++++++++---- .../CloseIoApiWrapper/Model/Opportunity.php | 130 +++++++++++++----- .../CloseIoApiWrapper/Model/Phone.php | 19 ++- .../CloseIoApiWrapper/Model/Task.php | 89 +++++++++--- .../CloseIoApiWrapper/Model/Url.php | 24 ++-- 8 files changed, 389 insertions(+), 133 deletions(-) diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Address.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Address.php index 0a28048..050705f 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Address.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Address.php @@ -1,11 +1,11 @@ hydrate($data, [], array('setAddress_1' => 'setAddress1', 'setAddress_2' => 'setAddress2')); + $this->hydrate($data, [], ['setAddress_1' => 'setAddress1', 'setAddress_2' => 'setAddress2']); } } @@ -71,11 +71,14 @@ public function getAddress1() } /** - * @param string $address_1 + * @param $address_1 + * @return $this */ public function setAddress1($address_1) { $this->address_1 = $address_1; + + return $this; } /** @@ -87,11 +90,14 @@ public function getAddress2() } /** - * @param string $address_2 + * @param $address_2 + * @return $this */ public function setAddress2($address_2) { $this->address_2 = $address_2; + + return $this; } /** @@ -103,11 +109,14 @@ public function getCity() } /** - * @param string $city + * @param $city + * @return $this */ public function setCity($city) { $this->city = $city; + + return $this; } /** @@ -119,11 +128,14 @@ public function getCountry() } /** - * @param string $country + * @param $country + * @return $this */ public function setCountry($country) { $this->country = $country; + + return $this; } /** @@ -135,11 +147,14 @@ public function getLabel() } /** - * @param string $label + * @param $label + * @return $this */ public function setLabel($label) { $this->label = $label; + + return $this; } /** @@ -151,11 +166,14 @@ public function getState() } /** - * @param string $state + * @param $state + * @return $this */ public function setState($state) { $this->state = $state; + + return $this; } /** @@ -167,10 +185,13 @@ public function getZipcode() } /** - * @param string $zipcode + * @param $zipcode + * @return $this */ public function setZipcode($zipcode) { $this->zipcode = $zipcode; + + return $this; } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Contact.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Contact.php index 7d33d73..06582d0 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Contact.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Contact.php @@ -1,11 +1,11 @@ emails[] = $email; + + return $this; } - + /** * @param Email[] $emails + * @return $this */ public function setEmails(array $emails) { $this->emails = $emails; + + return $this; } /** @@ -117,10 +123,13 @@ public function getName() /** * @param $name + * @return $this */ public function setName($name) { $this->name = $name; + + return $this; } /** @@ -133,18 +142,24 @@ public function getPhones() /** * @param Phone $phone + * @return $this */ public function addPhone(Phone $phone) { $this->phones[] = $phone; + + return $this; } - + /** * @param Phone[] $phones + * @return $this */ public function setPhones(array $phones) { $this->phones = $phones; + + return $this; } /** @@ -157,10 +172,13 @@ public function getTitle() /** * @param $title + * @return $this */ public function setTitle($title) { $this->title = $title; + + return $this; } /** @@ -173,10 +191,13 @@ public function getCreatedBy() /** * @param $created_by + * @return $this */ public function setCreatedBy($created_by) { $this->created_by = $created_by; + + return $this; } /** @@ -189,10 +210,13 @@ public function getDateCreated() /** * @param $date_created + * @return $this */ public function setDateCreated($date_created) { $this->date_created = $date_created; + + return $this; } /** @@ -205,10 +229,13 @@ public function getDateUpdated() /** * @param $date_updated + * @return $this */ public function setDateUpdated($date_updated) { $this->date_updated = $date_updated; + + return $this; } /** @@ -221,10 +248,13 @@ public function getId() /** * @param $id + * @return $this */ public function setId($id) { $this->id = $id; + + return $this; } /** @@ -237,10 +267,13 @@ public function getOrganizationId() /** * @param $organization_id + * @return $this */ public function setOrganizationId($organization_id) { $this->organization_id = $organization_id; + + return $this; } /** @@ -252,11 +285,14 @@ public function getUpdatedBy() } /** - * @param string $updated_by + * @param $updated_by + * @return $this */ public function setUpdatedBy($updated_by) { $this->updated_by = $updated_by; + + return $this; } /** @@ -268,10 +304,13 @@ public function getUrls() } /** - * @param $urls + * @param Url[] $urls + * @return $this */ - public function setUrls($urls) + public function setUrls(array $urls) { $this->urls = $urls; + + return $this; } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Email.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Email.php index 1724ded..db3418d 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Email.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Email.php @@ -1,17 +1,17 @@ email = $email; } + + return $this; } /** @@ -74,10 +77,13 @@ public function getType() } /** - * @param string $type + * @param $type + * @return $this */ public function setType($type) { $this->type = $type; + + return $this; } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Lead.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Lead.php index a734b3d..2810250 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Lead.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Lead.php @@ -1,18 +1,17 @@ setCustom($data['custom']); unset($data['custom']); } @@ -158,10 +157,13 @@ public function getId() /** * @param $id + * @return $this */ public function setId($id) { $this->id = $id; + + return $this; } /** @@ -174,18 +176,24 @@ public function getAddresses() /** * @param Address $address + * @return $this */ - public function addAddress($address) + public function addAddress(Address $address) { $this->addresses[] = $address; + + return $this; } - + /** * @param Address[] $addresses + * @return $this */ public function setAddresses(array $addresses) { $this->addresses = $addresses; + + return $this; } /** @@ -198,18 +206,24 @@ public function getContacts() /** * @param Contact $contact + * @return $this */ public function addContact(Contact $contact) { $this->contacts[] = $contact; + + return $this; } - + /** * @param Contact[] $contacts + * @return $this */ public function setContacts(array $contacts) { $this->contacts = $contacts; + + return $this; } /** @@ -221,11 +235,14 @@ public function getCreatedBy() } /** - * @param string $created_by + * @param $created_by + * @return $this */ public function setCreatedBy($created_by) { $this->created_by = $created_by; + + return $this; } /** @@ -237,15 +254,18 @@ public function getCustom() } /** - * @param array $custom + * @param $custom + * @return $this */ public function setCustom($custom) { $this->custom = $custom; + + return $this; } /** - * @return \DateTime + * @return string */ public function getDateCreated() { @@ -253,11 +273,14 @@ public function getDateCreated() } /** - * @param \DateTime $date_created + * @param $date_created + * @return $this */ public function setDateCreated($date_created) { $this->date_created = $date_created; + + return $this; } /** @@ -269,11 +292,14 @@ public function getDescription() } /** - * @param string $description + * @param $description + * @return $this */ public function setDescription($description) { $this->description = $description; + + return $this; } /** @@ -285,11 +311,14 @@ public function getDisplayName() } /** - * @param string $display_name + * @param $display_name + * @return $this */ public function setDisplayName($display_name) { $this->display_name = $display_name; + + return $this; } /** @@ -301,11 +330,14 @@ public function getName() } /** - * @param string $name + * @param $name + * @return $this */ public function setName($name) { $this->name = $name; + + return $this; } /** @@ -318,10 +350,13 @@ public function getOpportunities() /** * @param Opportunity[] $opportunities + * @return $this */ - public function setOpportunities($opportunities) + public function setOpportunities(array $opportunities) { $this->opportunities = $opportunities; + + return $this; } /** @@ -334,10 +369,13 @@ public function getOrganization() /** * @param $organization + * @return $this */ public function setOrganization($organization) { $this->organization = $organization; + + return $this; } /** @@ -349,11 +387,14 @@ public function getStatusId() } /** - * @param string $status + * @param $status + * @return $this */ public function setStatusId($status) { $this->status_id = $status; + + return $this; } /** @@ -365,11 +406,14 @@ public function getStatusLabel() } /** - * @param string $status_label + * @param $status_label + * @return $this */ public function setStatusLabel($status_label) { $this->status_label = $status_label; + + return $this; } /** @@ -382,10 +426,13 @@ public function getTasks() /** * @param Task[] $tasks + * @return $this */ public function setTasks($tasks) { $this->tasks = $tasks; + + return $this; } /** @@ -398,16 +445,19 @@ public function getUrl() /** * @param $url + * @return $this * @throws InvalidUrlException */ public function setUrl($url) { // validate url - if (filter_var($url, FILTER_VALIDATE_URL)){ + if (filter_var($url, FILTER_VALIDATE_URL)) { $this->url = $url; } else { throw new InvalidUrlException('"' . $url . '" is not a valid URL'); } + + return $this; } /** @@ -419,11 +469,14 @@ public function getCreatedByName() } /** - * @param string $created_by_name + * @param $created_by_name + * @return $this */ public function setCreatedByName($created_by_name) { $this->created_by_name = $created_by_name; + + return $this; } /** @@ -435,11 +488,14 @@ public function getDateUpdated() } /** - * @param string $date_updated + * @param $date_updated + * @return $this */ public function setDateUpdated($date_updated) { $this->date_updated = $date_updated; + + return $this; } /** @@ -451,11 +507,14 @@ public function getHtmlUrl() } /** - * @param string $html_url + * @param $html_url + * @return $this */ public function setHtmlUrl($html_url) { $this->html_url = $html_url; + + return $this; } /** @@ -467,11 +526,14 @@ public function getOrganizationId() } /** - * @param string $organization_id + * @param $organization_id + * @return $this */ public function setOrganizationId($organization_id) { $this->organization_id = $organization_id; + + return $this; } /** @@ -483,11 +545,14 @@ public function getUpdatedBy() } /** - * @param string $updated_by + * @param $updated_by + * @return $this */ public function setUpdatedBy($updated_by) { $this->updated_by = $updated_by; + + return $this; } /** @@ -499,10 +564,13 @@ public function getUpdatedByName() } /** - * @param string $updated_by_name + * @param $updated_by_name + * @return $this */ public function setUpdatedByName($updated_by_name) { $this->updated_by_name = $updated_by_name; + + return $this; } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Opportunity.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Opportunity.php index 95f9e35..8602fd0 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Opportunity.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Opportunity.php @@ -1,17 +1,17 @@ confidence = $confidence; } else { throw new InvalidParamException('Opportunity confidence must be of type int'); } + + return $this; } /** @@ -177,11 +180,14 @@ public function getCreatedBy() } /** - * @param string $created_by + * @param $created_by + * @return $this */ public function setCreatedBy($created_by) { $this->created_by = $created_by; + + return $this; } /** @@ -193,15 +199,18 @@ public function getDateCreated() } /** - * @param \DateTime $date_created + * @param $date_created + * @return $this */ public function setDateCreated($date_created) { $this->date_created = $date_created; + + return $this; } /** - * @return \DateTime + * @return string */ public function getDateWon() { @@ -209,11 +218,14 @@ public function getDateWon() } /** - * @param \DateTime $date_won + * @param $date_won + * @return $this */ public function setDateWon($date_won) { $this->date_won = $date_won; + + return $this; } /** @@ -225,11 +237,14 @@ public function getLeadName() } /** - * @param string $lead_name + * @param $lead_name + * @return $this */ public function setLeadName($lead_name) { $this->lead_name = $lead_name; + + return $this; } /** @@ -241,11 +256,14 @@ public function getNote() } /** - * @param string $note + * @param $note + * @return $this */ public function setNote($note) { $this->note = $note; + + return $this; } /** @@ -257,11 +275,14 @@ public function getUserName() } /** - * @param string $user_name + * @param $user_name + * @return $this */ public function setUserName($user_name) { $this->user_name = $user_name; + + return $this; } /** @@ -273,11 +294,14 @@ public function getValuePeriod() } /** - * @param string $value_period + * @param $value_period + * @return $this */ public function setValuePeriod($value_period) { $this->value_period = $value_period; + + return $this; } /** @@ -289,11 +313,14 @@ public function getContactId() } /** - * @param string $contact_id + * @param $contact_id + * @return $this */ public function setContactId($contact_id) { $this->contact_id = $contact_id; + + return $this; } /** @@ -305,11 +332,14 @@ public function getCreatedByName() } /** - * @param string $created_by_name + * @param $created_by_name + * @return $this */ public function setCreatedByName($created_by_name) { $this->created_by_name = $created_by_name; + + return $this; } /** @@ -321,11 +351,14 @@ public function getDateLost() } /** - * @param string $date_lost + * @param $date_lost + * @return $this */ public function setDateLost($date_lost) { $this->date_lost = $date_lost; + + return $this; } /** @@ -337,11 +370,14 @@ public function getDateUpdated() } /** - * @param string $date_updated + * @param $date_updated + * @return $this */ public function setDateUpdated($date_updated) { $this->date_updated = $date_updated; + + return $this; } /** @@ -353,11 +389,14 @@ public function getId() } /** - * @param string $id + * @param $id + * @return $this */ public function setId($id) { $this->id = $id; + + return $this; } /** @@ -369,11 +408,14 @@ public function getLeadId() } /** - * @param string $lead_id + * @param $lead_id + * @return $this */ public function setLeadId($lead_id) { $this->lead_id = $lead_id; + + return $this; } /** @@ -385,11 +427,14 @@ public function getOrganizationId() } /** - * @param string $organization_id + * @param $organization_id + * @return $this */ public function setOrganizationId($organization_id) { $this->organization_id = $organization_id; + + return $this; } /** @@ -401,11 +446,14 @@ public function getStatusId() } /** - * @param string $status_id + * @param $status_id + * @return $this */ public function setStatusId($status_id) { $this->status_id = $status_id; + + return $this; } /** @@ -417,11 +465,14 @@ public function getStatusLabel() } /** - * @param string $status_label + * @param $status_label + * @return $this */ public function setStatusLabel($status_label) { $this->status_label = $status_label; + + return $this; } /** @@ -433,11 +484,14 @@ public function getStatusType() } /** - * @param string $status_type + * @param $status_type + * @return $this */ public function setStatusType($status_type) { $this->status_type = $status_type; + + return $this; } /** @@ -449,11 +503,14 @@ public function getUpdatedBy() } /** - * @param string $updated_by + * @param $updated_by + * @return $this */ public function setUpdatedBy($updated_by) { $this->updated_by = $updated_by; + + return $this; } /** @@ -465,11 +522,14 @@ public function getUpdatedByName() } /** - * @param string $updated_by_name + * @param $updated_by_name + * @return $this */ public function setUpdatedByName($updated_by_name) { $this->updated_by_name = $updated_by_name; + + return $this; } /** @@ -481,11 +541,14 @@ public function getUserId() } /** - * @param string $user_id + * @param $user_id + * @return $this */ public function setUserId($user_id) { $this->user_id = $user_id; + + return $this; } /** @@ -497,12 +560,13 @@ public function getValue() } /** - * @param string $value + * @param $value + * @return $this */ public function setValue($value) { $this->value = $value; - } - + return $this; + } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Phone.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Phone.php index b75f28d..853127e 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Phone.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Phone.php @@ -9,8 +9,8 @@ namespace LooplineSystems\CloseIoApiWrapper\Model; -use LooplineSystems\CloseIoApiWrapper\Library\ObjectHydrateHelperTrait; use LooplineSystems\CloseIoApiWrapper\Library\JsonSerializableHelperTrait; +use LooplineSystems\CloseIoApiWrapper\Library\ObjectHydrateHelperTrait; class Phone implements \JsonSerializable { @@ -57,11 +57,14 @@ public function getPhone() } /** - * @param string $phone + * @param $phone + * @return $this */ public function setPhone($phone) { $this->phone = $phone; + + return $this; } /** @@ -73,11 +76,14 @@ public function getType() } /** - * @param string $type + * @param $type + * @return $this */ public function setType($type) { $this->type = $type; + + return $this; } /** @@ -89,12 +95,13 @@ public function getPhoneFormatted() } /** - * @param string $phone_formatted + * @param $phone_formatted + * @return $this */ public function setPhoneFormatted($phone_formatted) { $this->phone_formatted = $phone_formatted; - } - + return $this; + } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Task.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Task.php index 9393559..57cfc9e 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Task.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Task.php @@ -1,11 +1,11 @@ assigned_to = $assigned_to; + + return $this; } /** @@ -126,11 +129,14 @@ public function getDueDate() } /** - * @param string $due_date + * @param $due_date + * @return $this */ public function setDueDate($due_date) { $this->due_date = $due_date; + + return $this; } /** @@ -142,11 +148,14 @@ public function isCompleted() } /** - * @param boolean $is_complete + * @param $is_complete + * @return $this */ public function setCompleted($is_complete) { $this->completed = $is_complete; + + return $this; } /** @@ -158,11 +167,14 @@ public function getLeadName() } /** - * @param string $lead_name + * @param $lead_name + * @return $this */ public function setLeadName($lead_name) { $this->lead_name = $lead_name; + + return $this; } /** @@ -174,11 +186,14 @@ public function getText() } /** - * @param string $text + * @param $text + * @return $this */ public function setText($text) { $this->text = $text; + + return $this; } /** @@ -190,11 +205,14 @@ public function getAssignedToName() } /** - * @param string $assigned_to_name + * @param $assigned_to_name + * @return $this */ public function setAssignedToName($assigned_to_name) { $this->assigned_to_name = $assigned_to_name; + + return $this; } /** @@ -206,11 +224,14 @@ public function getCreatedBy() } /** - * @param string $created_by + * @param $created_by + * @return $this */ public function setCreatedBy($created_by) { $this->created_by = $created_by; + + return $this; } /** @@ -222,11 +243,14 @@ public function getCreatedByName() } /** - * @param string $created_by_name + * @param $created_by_name + * @return $this */ public function setCreatedByName($created_by_name) { $this->created_by_name = $created_by_name; + + return $this; } /** @@ -238,11 +262,14 @@ public function getDateUpdated() } /** - * @param string $date_updated + * @param $date_updated + * @return $this */ public function setDateUpdated($date_updated) { $this->date_updated = $date_updated; + + return $this; } /** @@ -254,11 +281,14 @@ public function getId() } /** - * @param string $id + * @param $id + * @return $this */ public function setId($id) { $this->id = $id; + + return $this; } /** @@ -270,11 +300,14 @@ public function getLeadId() } /** - * @param string $lead_id + * @param $lead_id + * @return $this */ public function setLeadId($lead_id) { $this->lead_id = $lead_id; + + return $this; } /** @@ -286,11 +319,14 @@ public function getOrganizationId() } /** - * @param string $organization_id + * @param $organization_id + * @return $this */ public function setOrganizationId($organization_id) { $this->organization_id = $organization_id; + + return $this; } /** @@ -302,11 +338,14 @@ public function getUpdatedBy() } /** - * @param string $updated_by + * @param $updated_by + * @return $this */ public function setUpdatedBy($updated_by) { $this->updated_by = $updated_by; + + return $this; } /** @@ -318,15 +357,18 @@ public function getUpdatedByName() } /** - * @param string $updated_by_name + * @param $updated_by_name + * @return $this */ public function setUpdatedByName($updated_by_name) { $this->updated_by_name = $updated_by_name; + + return $this; } /** - * @return mixed + * @return string */ public function getDateCreated() { @@ -334,10 +376,13 @@ public function getDateCreated() } /** - * @param mixed $date_created + * @param $date_created + * @return $this */ public function setDateCreated($date_created) { $this->date_created = $date_created; + + return $this; } } diff --git a/src/LooplineSystems/CloseIoApiWrapper/Model/Url.php b/src/LooplineSystems/CloseIoApiWrapper/Model/Url.php index c384074..526a9b2 100644 --- a/src/LooplineSystems/CloseIoApiWrapper/Model/Url.php +++ b/src/LooplineSystems/CloseIoApiWrapper/Model/Url.php @@ -1,16 +1,16 @@ type = $type; + + return $this; } /** @@ -65,10 +68,13 @@ public function getUrl() } /** - * @param string $url + * @param $url + * @return $this */ public function setUrl($url) { $this->url = $url; + + return $this; } }