Completed
Push — develop ( d04237...676fe2 )
by Jens
20:02
created

Payment::getAmountPaid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Payment;
7
8
use Commercetools\Core\Model\Common\Resource;
9
use Commercetools\Core\Model\Common\DateTimeDecorator;
10
use Commercetools\Core\Model\Customer\CustomerReference;
11
use Commercetools\Core\Model\Common\Money;
12
use Commercetools\Core\Model\CustomField\CustomFieldObject;
13
use Commercetools\Core\Model\CustomField\CustomFieldObjectCollection;
14
use DateTime;
15
16
/**
17
 * @package Commercetools\Core\Model\Payment
18
 * @link https://dev.commercetools.com/http-api-projects-payments.html#payment
19
 * @method string getId()
20
 * @method Payment setId(string $id = null)
21
 * @method int getVersion()
22
 * @method Payment setVersion(int $version = null)
23
 * @method DateTimeDecorator getCreatedAt()
24
 * @method Payment setCreatedAt(DateTime $createdAt = null)
25
 * @method DateTimeDecorator getLastModifiedAt()
26
 * @method Payment setLastModifiedAt(DateTime $lastModifiedAt = null)
27
 * @method CustomerReference getCustomer()
28
 * @method Payment setCustomer(CustomerReference $customer = null)
29
 * @method string getInterfaceId()
30
 * @method Payment setInterfaceId(string $interfaceId = null)
31
 * @method Money getAmountPlanned()
32
 * @method Payment setAmountPlanned(Money $amountPlanned = null)
33
 * @method PaymentMethodInfo getPaymentMethodInfo()
34
 * @method Payment setPaymentMethodInfo(PaymentMethodInfo $paymentMethodInfo = null)
35
 * @method CustomFieldObject getCustom()
36
 * @method Payment setCustom(CustomFieldObject $custom = null)
37
 * @method PaymentStatus getPaymentStatus()
38
 * @method Payment setPaymentStatus(PaymentStatus $paymentStatus = null)
39
 * @method TransactionCollection getTransactions()
40
 * @method Payment setTransactions(TransactionCollection $transactions = null)
41
 * @method CustomFieldObjectCollection getInterfaceInteractions()
42
 * @method Payment setInterfaceInteractions(CustomFieldObjectCollection $interfaceInteractions = null)
43
 * @method string getKey()
44
 * @method Payment setKey(string $key = null)
45
 * @method PaymentReference getReference()
46
 */
47
class Payment extends Resource
48
{
49 24
    public function fieldDefinitions()
50
    {
51
        return [
52 24
            'id' => [static::TYPE => 'string'],
53 24
            'version' => [static::TYPE => 'int'],
54 24
            'key' => [static::TYPE => 'string'],
55
            'createdAt' => [
56 24
                static::TYPE => DateTime::class,
57 24
                static::DECORATOR => DateTimeDecorator::class
58
            ],
59
            'lastModifiedAt' => [
60 24
                static::TYPE => DateTime::class,
61 24
                static::DECORATOR => DateTimeDecorator::class
62
            ],
63 24
            'customer' => [static::TYPE => CustomerReference::class],
64 24
            'externalId' => [static::TYPE => 'string'],
65 24
            'interfaceId' => [static::TYPE => 'string'],
66 24
            'amountPlanned' => [static::TYPE => Money::class],
67 24
            'amountAuthorized' => [static::TYPE => Money::class],
68
            'authorizedUntil' => [
69 24
                static::TYPE => DateTime::class,
70 24
                static::DECORATOR => DateTimeDecorator::class
71
            ],
72 24
            'amountPaid' => [static::TYPE => Money::class],
73 24
            'amountRefunded' => [static::TYPE => Money::class],
74 24
            'paymentMethodInfo' => [static::TYPE => PaymentMethodInfo::class],
75 24
            'custom' => [static::TYPE => CustomFieldObject::class],
76 24
            'paymentStatus' => [static::TYPE => PaymentStatus::class],
77 24
            'transactions' => [static::TYPE => TransactionCollection::class],
78
            'interfaceInteractions' => [
79 24
                static::TYPE => CustomFieldObjectCollection::class
80
            ],
81
        ];
82
    }
83
84
    /**
85
     * @deprecated
86
     * @return string
87
     */
88 1
    public function getExternalId()
89
    {
90 1
        return parent::getExternalId();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method getExternalId() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Category\Category, Commercetools\Core\Model\Customer\Customer, Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
91
    }
92
93
    /**
94
     * @deprecated
95
     * @param string $externalId
96
     * @return static
97
     */
98
    public function setExternalId($externalId = null)
99
    {
100
        return parent::setExternalId($externalId);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method setExternalId() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Category\Category, Commercetools\Core\Model\Customer\Customer, Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
101
    }
102
103
    /**
104
     * @deprecated
105
     * @return Money
106
     */
107 1
    public function getAmountAuthorized()
108
    {
109 1
        return parent::getAmountAuthorized();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method getAmountAuthorized() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
110
    }
111
112
    /**
113
     * @deprecated
114
     * @param Money $amountAuthorized
115
     * @return static
116
     */
117
    public function setAmountAuthorized(Money $amountAuthorized = null)
118
    {
119
        return parent::setAmountAuthorized($amountAuthorized);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method setAmountAuthorized() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
120
    }
121
122
    /**
123
     * @deprecated
124
     * @return Money
125
     */
126 1
    public function getAmountPaid()
127
    {
128 1
        return parent::getAmountPaid();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method getAmountPaid() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
129
    }
130
131
    /**
132
     * @deprecated
133
     * @param Money $amountPaid
134
     * @return static
135
     */
136
    public function setAmountPaid(Money $amountPaid = null)
137
    {
138
        return parent::setAmountPaid($amountPaid);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method setAmountPaid() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
139
    }
140
141
    /**
142
     * @deprecated
143
     * @return Money
144
     */
145 1
    public function getAmountRefunded()
146
    {
147 1
        return parent::getAmountRefunded();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method getAmountRefunded() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
148
    }
149
150
    /**
151
     * @deprecated
152
     * @param Money $amountRefunded
153
     * @return static
154
     */
155
    public function setAmountRefunded(Money $amountRefunded = null)
156
    {
157
        return parent::setAmountRefunded($amountRefunded);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method setAmountRefunded() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
158
    }
159
160
    /**
161
     * @deprecated
162
     * @return Money
163
     */
164 1
    public function getAuthorizedUntil()
165
    {
166 1
        return parent::getAuthorizedUntil();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method getAuthorizedUntil() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
167
    }
168
169
    /**
170
     * @deprecated
171
     * @param Money $amountUntil
172
     * @return static
173
     */
174
    public function setAuthorizedUntil(Money $amountUntil = null)
175
    {
176
        return parent::setAuthorizedUntil($amountUntil);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Commercetools\Core\Model\Common\Resource as the method setAuthorizedUntil() does only exist in the following sub-classes of Commercetools\Core\Model\Common\Resource: Commercetools\Core\Model\Payment\Payment. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
177
    }
178
}
179