Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace League\Flysystem;
6
 
7
class DirectoryAttributes implements StorageAttributes
8
{
9
    use ProxyArrayAccessToProperties;
10
    private string $type = StorageAttributes::TYPE_DIRECTORY;
11
 
12
    public function __construct(
13
        private string $path,
14
        private ?string $visibility = null,
15
        private ?int $lastModified = null,
16
        private array $extraMetadata = [])
17
    {
18
        $this->path = trim($this->path, '/');
19
    }
20
 
21
    public function path(): string
22
    {
23
        return $this->path;
24
    }
25
 
26
    public function type(): string
27
    {
28
        return $this->type;
29
    }
30
 
31
    public function visibility(): ?string
32
    {
33
        return $this->visibility;
34
    }
35
 
36
    public function lastModified(): ?int
37
    {
38
        return $this->lastModified;
39
    }
40
 
41
    public function extraMetadata(): array
42
    {
43
        return $this->extraMetadata;
44
    }
45
 
46
    public function isFile(): bool
47
    {
48
        return false;
49
    }
50
 
51
    public function isDir(): bool
52
    {
53
        return true;
54
    }
55
 
56
    public function withPath(string $path): self
57
    {
58
        $clone = clone $this;
59
        $clone->path = $path;
60
 
61
        return $clone;
62
    }
63
 
64
    public static function fromArray(array $attributes): self
65
    {
66
        return new DirectoryAttributes(
67
            $attributes[StorageAttributes::ATTRIBUTE_PATH],
68
            $attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null,
69
            $attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null,
70
            $attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? []
71
        );
72
    }
73
 
74
    /**
75
     * @inheritDoc
76
     */
77
    public function jsonSerialize(): array
78
    {
79
        return [
80
            StorageAttributes::ATTRIBUTE_TYPE => $this->type,
81
            StorageAttributes::ATTRIBUTE_PATH => $this->path,
82
            StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility,
83
            StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified,
84
            StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata,
85
        ];
86
    }
87
}