ConstraintException::getUploadedFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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