Issues (139)

Model/Data/NumberToken.php (1 issue)

1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
declare(strict_types=1);
10
11
namespace Getnet\PaymentMagento\Model\Data;
12
13
use Getnet\PaymentMagento\Api\Data\NumberTokenInterface;
14
use Magento\Framework\Api\AbstractSimpleObject;
15
16
/**
17
 * Class Number Token - Model data.
18
 */
19
class NumberToken extends AbstractSimpleObject implements NumberTokenInterface
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public function getCardNumber()
25
    {
26
        return $this->_get(NumberTokenInterface::GETNET_CARD_NUMBER);
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function setCardNumber($cardNumber)
33
    {
34
        return $this->setData(NumberTokenInterface::GETNET_CARD_NUMBER, $cardNumber);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->setData(Ge...RD_NUMBER, $cardNumber) returns the type Getnet\PaymentMagento\Model\Data\NumberToken which is incompatible with the return type mandated by Getnet\PaymentMagento\Ap...erface::setCardNumber() of void.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
35
    }
36
}
37