Service   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 36
c 1
b 0
f 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A addLiqpayPayment() 0 26 1
1
<?php
2
3
/**
4
 * @namespace
5
 */
6
7
namespace Application\Payments;
8
9
use Application\Options\Table as OptionsTable;
0 ignored issues
show
Bug introduced by
The type Application\Options\Table was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Application\Payments\Table as PaymentsTable;
11
use Application\Transactions\Table as TransactionsTable;
0 ignored issues
show
Bug introduced by
The type Application\Transactions\Table was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class Service
14
{
15
    /**
16
     * Add Debit record
17
     *
18
     * @param int $userId
19
     * @param array $data
20
     *
21
     * @return \Application\Wallets\Row|bool
0 ignored issues
show
Bug introduced by
The type Application\Wallets\Row was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
     */
23
    public static function addLiqpayPayment(int $userId, array $data)
24
    {
25
        return Db::transaction(function () use ($userId, $data) {
0 ignored issues
show
Bug introduced by
The type Application\Payments\Db was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
            $value = ceil($data['amount'] / OptionsTable::get('price')) * 1000;
28
29
            $transaction = TransactionsTable::create();
30
            $transaction->userId = $userId;
31
            $transaction->amount = $value;
32
            $transaction->type = TransactionsTable::TYPE_DEBIT;
33
            $transaction->save();
34
35
            $wallet = self::getWallet($userId);
0 ignored issues
show
Bug introduced by
The method getWallet() does not exist on Application\Payments\Service. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            /** @scrutinizer ignore-call */ 
36
            $wallet = self::getWallet($userId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
            $wallet->amount += $transaction->amount;
37
            $wallet->save();
38
39
            $payment = PaymentsTable::create();
40
            $payment->amount = $data['amount'];
41
            $payment->currency = $data['currency'];
42
            $payment->provider = PaymentsTable::PROVIDER_LIQPAY;
43
            $payment->foreignId = $data['payment_id'];
44
            $payment->transactionId = $transaction->id;
45
            $payment->rawData = \json_encode($data);
46
            $payment->save();
47
48
            return $transaction;
49
        });
50
    }
51
}