Completed
Pull Request — master (#2)
by
unknown
14:56
created

PurchaseRequest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 3
cbo 2
dl 0
loc 58
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrency() 0 4 1
A setCurrency() 0 4 1
A getLanguage() 0 4 1
A setLanguage() 0 4 1
A getSignatureValue() 0 4 1
A setSignatureValue() 0 4 1
A getData() 0 20 1
A sendData() 0 4 1
1
<?php
2
3
/*
4
 * RoboKassa driver for the Omnipay PHP payment processing library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-epayservice
7
 * @package   omnipay-epayservice
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\RoboKassa\Message;
13
14
class PurchaseRequest extends AbstractRequest
15
{
16
    public function getCurrency()
17
    {
18
        return $this->getParameter('currency');
19
    }
20
21
    public function setCurrency($value)
22
    {
23
        return $this->setParameter('currency', $value);
24
    }
25
26
    public function getLanguage()
27
    {
28
        return $this->getParameter('language');
29
    }
30
31
    public function setLanguage($value)
32
    {
33
        return $this->setParameter('language', $value);
34
    }
35
36
    public function getSignatureValue()
37
    {
38
        return $this->getParameter('signature');
39
    }
40
41
    public function setSignatureValue($value)
42
    {
43
        return $this->setParameter('signature', $value);
44
    }
45
46
    public function getData()
47
    {
48
        $this->validate(
49
            'purse',
50
            'amount', 'currency', 'description',
51
            'returnUrl', 'cancelUrl', 'notifyUrl'
52
        );
53
54
        return [
55
            'Desc' => $this->getDescription(),
56
            'MrchLogin' => $this->getPurse(),
57
            'OutSum' => $this->getAmount(),
58
            'IncCurrLabel' => $this->getCurrency(),
59
            'Culture' => $this->getLanguage(),
60
            'ShpCart' => $this->is_cart,
0 ignored issues
show
Bug introduced by
The property is_cart does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
61
            'ShpClient' => $this->client,
0 ignored issues
show
Bug introduced by
The property client does not seem to exist. Did you mean httpClient?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
62
            'ShpTime' => $this->time,
0 ignored issues
show
Bug introduced by
The property time does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
63
            'SignatureValue' => $this->getSignatureValue(),
64
        ];
65
    }
66
67
    public function sendData($data)
68
    {
69
        return $this->response = new PurchaseResponse($this, $data);
70
    }
71
}
72