CardId::getCardId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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\CardIdInterface;
14
use Magento\Framework\Api\AbstractSimpleObject;
15
16
/**
17
 * Class Card Id - Model data.
18
 */
19
class CardId extends AbstractSimpleObject implements CardIdInterface
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public function getCardId()
25
    {
26
        return $this->_get(CardIdInterface::GETNET_CARD_ID);
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function setCardId($cardId)
33
    {
34
        return $this->setData(CardIdInterface::GETNET_CARD_ID, $cardId);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->setData(Ge...ETNET_CARD_ID, $cardId) returns the type Getnet\PaymentMagento\Model\Data\CardId which is incompatible with the return type mandated by Getnet\PaymentMagento\Ap...dInterface::setCardId() 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