InvalidFieldValueException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 55
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A getField() 0 3 1
A setField() 0 10 2
1
<?php
2
3
namespace App\Exceptions;
4
5
class InvalidFieldValueException extends InvalidImportFileException
6
{
7
    /**
8
     * The invalid field.
9
     *
10
     * @var string
11
     */
12
    protected $field;
13
14
    /**
15
     * The invalid value.
16
     *
17
     * @var int|string
18
     */
19
    protected $value;
20
21
    /**
22
     * Get the field name of this exception.
23
     *
24
     * @return string
25
     */
26
    public function getField()
27
    {
28
        return $this->field;
29
    }
30
31
    /**
32
     * Get the field value of this exception.
33
     *
34
     * @return int|string
35
     */
36
    public function getValue()
37
    {
38
        return $this->value;
39
    }
40
41
    /**
42
     * Set the field name and value of this exception.
43
     *
44
     * @param string     $field
45
     * @param int|string $value
46
     * @param string     $message
47
     *
48
     * @return $this
49
     */
50
    public function setField($field, $value, $message = null)
51
    {
52
        $this->field = $field;
53
        $this->value = $value;
54
        if ($message === null) {
55
            $message = "The file contains an invalid value [{$value}] for the field [{$field}].";
56
        }
57
        $this->message = $message;
58
59
        return $this;
60
    }
61
}
62