Conditions | 10 |
Paths | 18 |
Total Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
70 | public function PayTransaction(){ |
||
71 | try { |
||
72 | $this->CheckTransaction(); |
||
73 | } catch (OsonException $e) { |
||
74 | if ($e->status != OsonException::SUCCESS) |
||
75 | $e->send(); |
||
76 | } |
||
77 | if (is_null($this->request['params']['trans']) || is_null($this->request['params']['trans']['time']) |
||
78 | || is_null($this->request['params']['trans']['transID'])) |
||
79 | throw new OsonException(OsonException::ERROR_INSUFFICIENT_PRIVILEGE,[]); |
||
80 | $order = Order::find($this->request['params']['trans']['login']); //todo login may change in feature |
||
81 | |||
82 | if ($order){ |
||
83 | if ($order->state == Order::STATE_PAY_ACCEPTED) |
||
84 | throw new OsonException(OsonException::ERROR_ALREADY_PAID, []); |
||
85 | if ($order->state != Order::STATE_WAITING_PAY) |
||
86 | throw new OsonException(OsonException::ERROR_ALREADY_PAID, []); |
||
87 | if ($order->price != $this->request['params']['trans']['amount']) |
||
88 | throw new OsonException(OsonException::ERROR_INVALID_AMOUNT, ['prividerTrnId' => $this->request['params']['trans']['transID'], 'ts' => $this->request['params']['trans']['time']]); |
||
89 | $order->changeState(Order::STATE_PAY_ACCEPTED); |
||
90 | } |
||
91 | $create_time = DataFormat::timestamp(true); |
||
92 | $transaction = new Transaction(); |
||
93 | $transaction->payment_system = Transaction::OSON; |
||
94 | $transaction->system_transaction_id = $this->request['params']['trans']['transID']; |
||
95 | $transaction->system_time = DataFormat::datetime2timestamp($this->request['params']['trans']['time']); |
||
96 | $transaction->system_time_datetime = $this->request['params']['trans']['time']; |
||
97 | $transaction->create_time = DataFormat::timestamp2datetime($create_time); |
||
98 | $transaction->state = Transaction::STATE_COMPLETED; |
||
99 | $transaction->amount = $this->request['params']['trans']['amount']; |
||
100 | $transaction->currency_code = Transaction::CODE_UZS; |
||
101 | $transaction->order_id = $this->request['params']['trans']['login']; |
||
102 | $transaction->save(); |
||
103 | |||
104 | throw new OsonException(OsonException::SUCCESS,['prividerTrnId'=>$this->request['params']['trans']['transID'],'ts'=>$this->request['params']['trans']['time'],'order_state'=>Order::STATE_PAY_ACCEPTED]); |
||
105 | |||
106 | } |
||
107 | public static function getRedirectParams($order) |
||
118 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.