Code Duplication    Length = 23-28 lines in 2 locations

src/cart/AbstractServerPurchase.php 1 location

@@ 17-44 (lines=28) @@
14
/**
15
 * Abstract class AbstractServerPurchase.
16
 */
17
abstract class AbstractServerPurchase extends \hipanel\modules\finance\cart\AbstractPurchase
18
{
19
    use \hipanel\base\ModelTrait;
20
21
    /** {@inheritdoc} */
22
    public static function type()
23
    {
24
        return 'server';
25
    }
26
27
    /** {@inheritdoc} */
28
    public function init()
29
    {
30
        parent::init();
31
32
        $this->server = $this->position->name;
33
        $this->amount = $this->position->getQuantity();
34
    }
35
36
    /** {@inheritdoc} */
37
    public function rules()
38
    {
39
        return array_merge(parent::rules(), [
40
            [['server', 'expires'], 'safe'],
41
            [['amount'], 'number'],
42
        ]);
43
    }
44
}
45

src/cart/RenewCalculation.php 1 location

@@ 18-40 (lines=23) @@
15
 * Class RenewCalculation performs calculation for server renewal operation
16
 * @package hipanel\modules\server\cart
17
 */
18
class RenewCalculation extends \hipanel\modules\finance\models\Calculation
19
{
20
    use \hipanel\base\ModelTrait;
21
22
    /** {@inheritdoc} */
23
    public function init()
24
    {
25
        parent::init();
26
27
        $this->client = $this->position->getModel()->client;
28
        $this->seller = $this->position->getModel()->seller;
29
        $this->object = 'server';
30
    }
31
32
    /** {@inheritdoc} */
33
    public function rules()
34
    {
35
        return array_merge(parent::rules(), [
36
            [['server', 'expires'], 'safe'],
37
            [['id'], 'integer'],
38
        ]);
39
    }
40
}
41