Completed
Pull Request — master (#5)
by Beñat
03:29
created

RenameFileCommand::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\File\Application\Command\Rename;
14
15
use BenGorFile\File\Domain\Model\FileNameException;
16
17
/**
18
 * Rename file command class.
19
 *
20
 * @author Beñat Espiña <[email protected]>
21
 */
22
class RenameFileCommand
23
{
24
    /**
25
     * The file id.
26
     *
27
     * @var string
28
     */
29
    private $id;
30
31
    /**
32
     * The file name.
33
     *
34
     * @var string
35
     */
36
    private $name;
37
38
    /**
39
     * Constructor.
40
     *
41
     * @param string $anId  The file id
42
     * @param string $aName The file name
43
     *
44
     * @throws \InvalidArgumentException when the id or uploaded file given are null
45
     * @throws FileNameException         when the name given is null
46
     */
47
    public function __construct($anId, $aName)
48
    {
49
        if (null === $anId) {
50
            throw new \InvalidArgumentException('The file id cannot be null');
51
        }
52
        if (null === $aName) {
53
            throw FileNameException::invalidName($aName);
54
        }
55
        $this->id = $anId;
56
        $this->name = $aName;
57
    }
58
59
    /**
60
     * Gets the file id.
61
     *
62
     * @return string
63
     */
64
    public function id()
65
    {
66
        return $this->id;
67
    }
68
69
    /**
70
     * Gets the file name.
71
     *
72
     * @return string
73
     */
74
    public function name()
75
    {
76
        return $this->name;
77
    }
78
}
79