Completed
Push — master ( 5b123a...5e7977 )
by Freek
01:21
created

RemoteFile::getFilename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\MediaLibrary\Helpers;
4
5
class RemoteFile
6
{
7
    /**
8
     * The relative path to the file.
9
     *
10
     * @var string
11
     */
12
    protected $key;
13
14
    /**
15
     * The disk the file exists on.
16
     *
17
     * @var string
18
     */
19
    protected $disk;
20
21
    /**
22
     * Constructor method.
23
     *
24
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
25
     */
26
    public function __construct($key, $disk)
27
    {
28
        $this->key = $key;
29
        $this->disk = $disk;
30
    }
31
32
    /**
33
     * Get the key.
34
     *
35
     * @return string
36
     */
37
    public function getKey(): string
38
    {
39
        return $this->key;
40
    }
41
42
    /**
43
     * Get the disk.
44
     *
45
     * @return string
46
     */
47
    public function getDisk(): string
48
    {
49
        return $this->disk;
50
    }
51
52
    /**
53
     * Get the filename (including extension).
54
     *
55
     * @return string
56
     */
57
    public function getFilename()
58
    {
59
        return basename($this->key);
60
    }
61
62
    /**
63
     * Get the name (excluding extension).
64
     *
65
     * @return string
66
     */
67
    public function getName()
68
    {
69
        return pathinfo($this->getFilename(), PATHINFO_FILENAME);
70
    }
71
}
72