ConstraintException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 2
b 0
f 0
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUploadedFile() 0 3 1
A getConstraint() 0 3 1
1
<?php
2
3
namespace Slince\Upload\Exception;
4
5
use Slince\Upload\Constraint\ConstraintInterface;
6
use Symfony\Component\HttpFoundation\File\UploadedFile;
7
8
class ConstraintException extends UploadException
9
{
10
    /**
11
     * @var ConstraintInterface
12
     */
13
    protected $constraint;
14
15
    /**
16
     * @var UploadedFile
17
     */
18
    protected $uploadedFile;
19
20
    public function __construct(ConstraintInterface $constraint, UploadedFile $uploadedFile)
21
    {
22
        $this->constraint = $constraint;
23
        $this->uploadedFile = $uploadedFile;
24
        parent::__construct($constraint->getErrorMessage($uploadedFile));
25
    }
26
27
    /**
28
     * Gets the constraint
29
     *
30
     * @return ConstraintInterface
31
     */
32
    public function getConstraint(): ConstraintInterface
33
    {
34
        return $this->constraint;
35
    }
36
37
    /**
38
     * Gets the uploaded file
39
     *
40
     * @return UploadedFile
41
     */
42
    public function getUploadedFile(): UploadedFile
43
    {
44
        return $this->file;
45
    }
46
}
47