VoucherIsInvalid   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A withCode() 0 4 1
A __construct() 0 5 1
A getVoucherCode() 0 4 1
1
<?php
2
3
namespace BeyondCode\Vouchers\Exceptions;
4
5
class VoucherIsInvalid extends \Exception
6
{
7
    protected $code;
8
9
    public static function withCode(string $code)
10
    {
11
        return new static('The provided code '.$code.' is invalid.', $code);
12
    }
13
14
    public function __construct($message, $code)
15
    {
16
        $this->message = $message;
17
        $this->code = $code;
18
    }
19
20
    /**
21
     * @return mixed
22
     */
23
    public function getVoucherCode()
24
    {
25
        return $this->code;
26
    }
27
}