These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Finance module for HiPanel |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hipanel-module-finance |
||
6 | * @package hipanel-module-finance |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hipanel\modules\finance\cart; |
||
12 | |||
13 | use yii\base\InvalidConfigException; |
||
14 | |||
15 | /** |
||
16 | * Class Purchase. |
||
17 | * Performs purchase action. |
||
18 | * Holds cart position object and data needed to perform purchase:. |
||
19 | * |
||
20 | * @property int $amount |
||
21 | * @property string $client |
||
22 | * @property string $currency |
||
23 | * @property string object - object type e.g. `domain`, `server`, `certificate` |
||
24 | * |
||
25 | * @property string $calculation_id |
||
26 | */ |
||
27 | abstract class AbstractPurchase extends \hipanel\base\Model |
||
28 | { |
||
29 | use \hipanel\base\ModelTrait; |
||
30 | |||
31 | /** |
||
32 | * @var AbstractCartPosition |
||
33 | */ |
||
34 | public $position; |
||
35 | |||
36 | /** |
||
37 | * @var array result of purchase execution |
||
38 | */ |
||
39 | protected $_result; |
||
40 | |||
41 | public function getResult() |
||
42 | { |
||
43 | return $this->_result; |
||
44 | } |
||
45 | |||
46 | /** {@inheritdoc} */ |
||
47 | public static function tableName() |
||
48 | { |
||
49 | throw new InvalidConfigException('Method "tableName" must be declared'); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @throws InvalidConfigException |
||
54 | * @internal param string $ operation to be performed, e.g.: Renew, Transfer, Registration |
||
55 | */ |
||
56 | public static function operation() |
||
57 | { |
||
58 | throw new InvalidConfigException('Method "operation" must be implemented'); |
||
59 | } |
||
60 | |||
61 | /** {@inheritdoc} */ |
||
62 | public function init() |
||
63 | { |
||
64 | parent::init(); |
||
65 | |||
66 | $this->calculation_id = $this->position->getId(); |
||
67 | $this->amount = $this->position->getQuantity(); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Executes the purchase. |
||
72 | * Calls proper API commands to purchase the product. |
||
73 | * @throws ErrorPurchaseException in case of failed purchase |
||
74 | * @return true if the item was purchased successfully |
||
75 | */ |
||
76 | public function execute() |
||
77 | { |
||
78 | if ($this->validate()) { |
||
79 | $this->_result = static::perform(static::operation(), $this->getAttributes()); |
||
0 ignored issues
–
show
|
|||
80 | |||
81 | return true; |
||
82 | } |
||
83 | |||
84 | return false; |
||
85 | } |
||
86 | |||
87 | public function renderNotes() |
||
88 | { |
||
89 | return ''; |
||
90 | } |
||
91 | |||
92 | /** {@inheritdoc} */ |
||
93 | public function rules() |
||
94 | { |
||
95 | return [ |
||
96 | [['calculation_id', 'object', 'client', 'type', 'currency', 'item'], 'safe'], |
||
97 | [['amount'], 'number'], |
||
98 | ]; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @return string[] |
||
103 | */ |
||
104 | public function getPurchasabilityRules() |
||
105 | { |
||
106 | return []; |
||
107 | } |
||
108 | } |
||
109 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..