Completed
Push — master ( 073f2f...b2ba42 )
by Joachim
12:40
created

PaymentException::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
namespace Loevgaard\DandomainAltapayBundle\Exception;
3
4
use Loevgaard\DandomainAltapayBundle\Entity\PaymentInterface;
5
use Symfony\Component\HttpFoundation\Request;
6
7
class PaymentException extends Exception
8
{
9
    /**
10
     * @var Request
11
     */
12
    protected $request;
13
14
    /**
15
     * @var PaymentInterface
16
     */
17
    protected $payment;
18
19
    /**
20
     * @param string $message
21
     * @param Request $request
22
     * @param PaymentInterface $payment
23
     * @return PaymentException
24
     */
25 View Code Duplication
    public static function create(string $message, Request $request, PaymentInterface $payment) : PaymentException
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
26
    {
27
        $e = new static($message);
28
        $e->setRequest($request);
29
        $e->setPayment($payment);
30
        return $e;
31
    }
32
33
    /**
34
     * @return Request
35
     */
36
    public function getRequest(): Request
37
    {
38
        return $this->request;
39
    }
40
41
    /**
42
     * @param Request $request
43
     * @return PaymentException
44
     */
45
    public function setRequest(Request $request) : PaymentException
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
46
    {
47
        $this->request = $request;
48
        return $this;
49
    }
50
51
    /**
52
     * @return PaymentInterface
53
     */
54
    public function getPayment() : PaymentInterface
55
    {
56
        return $this->payment;
57
    }
58
59
    /**
60
     * @param PaymentInterface $payment
61
     * @return PaymentException
62
     */
63
    public function setPayment(PaymentInterface $payment) : PaymentException
64
    {
65
        $this->payment = $payment;
66
        return $this;
67
    }
68
}