This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Omnipay\FirstAtlanticCommerce\Message; |
||
4 | |||
5 | use Omnipay\FirstAtlanticCommerce\Message\AbstractRequest; |
||
6 | |||
7 | /** |
||
8 | * FACPG2 Tokenize Request |
||
9 | */ |
||
10 | View Code Duplication | class CreateCardRequest extends AbstractRequest |
|
0 ignored issues
–
show
|
|||
11 | { |
||
12 | /** |
||
0 ignored issues
–
show
|
|||
13 | * @var string; |
||
0 ignored issues
–
show
|
|||
14 | */ |
||
0 ignored issues
–
show
|
|||
15 | protected $requestName = 'TokenizeRequest'; |
||
0 ignored issues
–
show
|
|||
16 | |||
17 | /** |
||
0 ignored issues
–
show
|
|||
18 | * Returns the signature for the request. |
||
0 ignored issues
–
show
|
|||
19 | * |
||
0 ignored issues
–
show
|
|||
20 | * @return string base64 encoded sha1 hash of the merchantPassword, merchantId, |
||
0 ignored issues
–
show
|
|||
21 | * and acquirerId. |
||
0 ignored issues
–
show
|
|||
22 | */ |
||
0 ignored issues
–
show
|
|||
23 | protected function generateSignature() |
||
0 ignored issues
–
show
|
|||
24 | { |
||
0 ignored issues
–
show
|
|||
25 | $signature = $this->getMerchantPassword(); |
||
0 ignored issues
–
show
|
|||
26 | $signature .= $this->getMerchantId(); |
||
0 ignored issues
–
show
|
|||
27 | $signature .= $this->getAcquirerId(); |
||
0 ignored issues
–
show
|
|||
28 | |||
29 | return base64_encode( sha1($signature, true) ); |
||
0 ignored issues
–
show
|
|||
30 | } |
||
0 ignored issues
–
show
|
|||
31 | |||
32 | /** |
||
0 ignored issues
–
show
|
|||
33 | * Validate and construct the data for the request |
||
0 ignored issues
–
show
|
|||
34 | * |
||
0 ignored issues
–
show
|
|||
35 | * @return array |
||
0 ignored issues
–
show
|
|||
36 | */ |
||
0 ignored issues
–
show
|
|||
37 | public function getData() |
||
0 ignored issues
–
show
|
|||
38 | { |
||
0 ignored issues
–
show
|
|||
39 | $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'customerReference', 'card'); |
||
0 ignored issues
–
show
|
|||
40 | $this->getCard()->validate(); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | $data = [ |
||
0 ignored issues
–
show
|
|||
43 | 'CardNumber' => $this->getCard()->getNumber(), |
||
0 ignored issues
–
show
|
|||
44 | 'CustomerReference' => $this->getCustomerReference(), |
||
0 ignored issues
–
show
|
|||
45 | 'ExpiryDate' => $this->getCard()->getExpiryDate('my'), |
||
0 ignored issues
–
show
|
|||
46 | 'MerchantNumber' => $this->getMerchantId(), |
||
0 ignored issues
–
show
|
|||
47 | 'Signature' => $this->generateSignature() |
||
0 ignored issues
–
show
|
|||
48 | ]; |
||
0 ignored issues
–
show
|
|||
49 | |||
50 | return $data; |
||
0 ignored issues
–
show
|
|||
51 | } |
||
0 ignored issues
–
show
|
|||
52 | |||
53 | /** |
||
0 ignored issues
–
show
|
|||
54 | * Get the customer reference. |
||
0 ignored issues
–
show
|
|||
55 | * |
||
0 ignored issues
–
show
|
|||
56 | * @return string |
||
0 ignored issues
–
show
|
|||
57 | */ |
||
0 ignored issues
–
show
|
|||
58 | public function getCustomerReference() |
||
0 ignored issues
–
show
|
|||
59 | { |
||
0 ignored issues
–
show
|
|||
60 | return $this->getParameter('customerReference'); |
||
0 ignored issues
–
show
|
|||
61 | } |
||
0 ignored issues
–
show
|
|||
62 | |||
63 | /** |
||
0 ignored issues
–
show
|
|||
64 | * Set the customer reference. |
||
0 ignored issues
–
show
|
|||
65 | * |
||
0 ignored issues
–
show
|
|||
66 | * @param string $value |
||
0 ignored issues
–
show
|
|||
67 | */ |
||
0 ignored issues
–
show
|
|||
68 | public function setCustomerReference($value) |
||
0 ignored issues
–
show
|
|||
69 | { |
||
0 ignored issues
–
show
|
|||
70 | return $this->setParameter('customerReference', $value); |
||
0 ignored issues
–
show
|
|||
71 | } |
||
0 ignored issues
–
show
|
|||
72 | |||
73 | /** |
||
0 ignored issues
–
show
|
|||
74 | * Returns endpoint for tokenize requests |
||
0 ignored issues
–
show
|
|||
75 | * |
||
0 ignored issues
–
show
|
|||
76 | * @return string Endpoint URL |
||
0 ignored issues
–
show
|
|||
77 | */ |
||
0 ignored issues
–
show
|
|||
78 | protected function getEndpoint() |
||
0 ignored issues
–
show
|
|||
79 | { |
||
0 ignored issues
–
show
|
|||
80 | return parent::getEndpoint() . 'Tokenize'; |
||
0 ignored issues
–
show
|
|||
81 | } |
||
0 ignored issues
–
show
|
|||
82 | |||
83 | /** |
||
0 ignored issues
–
show
|
|||
84 | * Return the tokenize response object |
||
0 ignored issues
–
show
|
|||
85 | * |
||
0 ignored issues
–
show
|
|||
86 | * @param \SimpleXMLElement $xml Response xml object |
||
0 ignored issues
–
show
|
|||
87 | * |
||
0 ignored issues
–
show
|
|||
88 | * @return CreateCardResponse |
||
0 ignored issues
–
show
|
|||
89 | */ |
||
0 ignored issues
–
show
|
|||
90 | protected function newResponse($xml) |
||
0 ignored issues
–
show
|
|||
91 | { |
||
0 ignored issues
–
show
|
|||
92 | return new CreateCardResponse($this, $xml); |
||
0 ignored issues
–
show
The return type of
return new \Omnipay\Firs...dResponse($this, $xml); (Omnipay\FirstAtlanticCom...sage\CreateCardResponse ) is incompatible with the return type declared by the abstract method Omnipay\FirstAtlanticCom...actRequest::newResponse of type Omnipay\FirstAtlanticCom...ssage\ResponseInterface .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
93 | } |
||
0 ignored issues
–
show
|
|||
94 | |||
95 | } |
||
96 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.