Completed
Push — develop ( 17c567...8b47e8 )
by Jens
08:20
created

CustomerDraft::setLocale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 * @created: 11.02.15, 14:23
5
 */
6
7
namespace Commercetools\Core\Model\Customer;
8
9
use Commercetools\Core\Model\Common\Context;
10
use Commercetools\Core\Model\Common\JsonObject;
11
use Commercetools\Core\Model\Common\DateTimeDecorator;
12
use Commercetools\Core\Model\Common\LocaleTrait;
13
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference;
14
use Commercetools\Core\Model\Common\AddressCollection;
15
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
16
17
/**
18
 * @package Commercetools\Core\Model\Customer
19
 * @link https://dev.commercetools.com/http-api-projects-customers.html#customerdraft
20
 * @method string getCustomerNumber()
21
 * @method string getEmail()
22
 * @method string getTitle()
23
 * @method string getFirstName()
24
 * @method string getMiddleName()
25
 * @method string getLastName()
26
 * @method string getPassword()
27
 * @method string getAnonymousCartId()
28
 * @method string getExternalId()
29
 * @method CustomerDraft setCustomerNumber(string $customerNumber = null)
30
 * @method CustomerDraft setEmail(string $email = null)
31
 * @method CustomerDraft setTitle(string $title = null)
32
 * @method CustomerDraft setFirstName(string $firstName = null)
33
 * @method CustomerDraft setMiddleName(string $middleName = null)
34
 * @method CustomerDraft setLastName(string $lastName = null)
35
 * @method CustomerDraft setPassword(string $password = null)
36
 * @method CustomerDraft setAnonymousCartId(string $anonymousCartId = null)
37
 * @method CustomerDraft setExternalId(string $externalId = null)
38
 * @method DateTimeDecorator getDateOfBirth()
39
 * @method CustomerDraft setDateOfBirth(\DateTime $dateOfBirth = null)
40
 * @method string getCompanyName()
41
 * @method CustomerDraft setCompanyName(string $companyName = null)
42
 * @method string getVatId()
43
 * @method CustomerDraft setVatId(string $vatId = null)
44
 * @method bool getIsEmailVerified()
45
 * @method CustomerDraft setIsEmailVerified(bool $isEmailVerified = null)
46
 * @method CustomerGroupReference getCustomerGroup()
47
 * @method CustomerDraft setCustomerGroup(CustomerGroupReference $customerGroup = null)
48
 * @method AddressCollection getAddresses()
49
 * @method CustomerDraft setAddresses(AddressCollection $addresses = null)
50
 * @method int getDefaultShippingAddress()
51
 * @method CustomerDraft setDefaultShippingAddress(int $defaultShippingAddress = null)
52
 * @method int getDefaultBillingAddress()
53
 * @method CustomerDraft setDefaultBillingAddress(int $defaultBillingAddress = null)
54
 * @method CustomFieldObjectDraft getCustom()
55
 * @method CustomerDraft setCustom(CustomFieldObjectDraft $custom = null)
56
 * @method string getLocale()
57
 */
58
class CustomerDraft extends JsonObject
59
{
60
    use LocaleTrait;
61
62 101
    public function fieldDefinitions()
63
    {
64
        return [
65 101
            'customerNumber' => [static::TYPE => 'string'],
66 101
            'email' => [static::TYPE => 'string'],
67 101
            'title' => [static::TYPE => 'string'],
68 101
            'firstName' => [static::TYPE => 'string'],
69 101
            'middleName' => [static::TYPE => 'string'],
70 101
            'lastName' => [static::TYPE => 'string'],
71 101
            'password' => [static::TYPE => 'string'],
72 101
            'anonymousCartId' => [static::TYPE => 'string'],
73 101
            'externalId' => [static::TYPE => 'string'],
74
            'dateOfBirth' => [
75 101
                static::TYPE => '\DateTime',
76 101
                static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator'
77
            ],
78 101
            'companyName' => [static::TYPE => 'string'],
79 101
            'vatId' => [static::TYPE => 'string'],
80 101
            'isEmailVerified' => [static::TYPE => 'bool'],
81 101
            'customerGroup' => [static::TYPE => '\Commercetools\Core\Model\CustomerGroup\CustomerGroupReference'],
82 101
            'addresses' => [static::TYPE => '\Commercetools\Core\Model\Common\AddressCollection'],
83 101
            'defaultShippingAddress' => [static::TYPE => 'int'],
84 101
            'defaultBillingAddress' => [static::TYPE => 'int'],
85 101
            'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectDraft'],
86 101
            'locale' => [static::TYPE => 'string'],
87
        ];
88
    }
89
90
    /**
91
     * @param string $email
92
     * @param string $firstName
93
     * @param string $lastName
94
     * @param string $password
95
     * @param Context|callable $context
96
     * @return CustomerDraft
97
     */
98 101 View Code Duplication
    public static function ofEmailNameAndPassword($email, $firstName, $lastName, $password, $context = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
    {
100 101
        $draft = static::of($context);
101 101
        return $draft->setEmail($email)
102 101
            ->setFirstName($firstName)
103 101
            ->setLastName($lastName)
104 101
            ->setPassword($password);
105
    }
106
}
107