PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.1
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / vendor / league / flysystem / src / FileAttributes.php

FileAttributes.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.1, at vendor/league/flysystem/src/FileAttributes.php

101 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace League\Flysystem;
6
7 class FileAttributes implements StorageAttributes
8 {
9 use ProxyArrayAccessToProperties;
10 private string $type = StorageAttributes::TYPE_FILE;
11
12 public function __construct(
13 private string $path,
14 private ?int $fileSize = null,
15 private ?string $visibility = null,
16 private ?int $lastModified = null,
17 private ?string $mimeType = null,
18 private array $extraMetadata = []
19 ) {
20 $this->path = ltrim($this->path, '/');
21 }
22
23 public function type(): string
24 {
25 return $this->type;
26 }
27
28 public function path(): string
29 {
30 return $this->path;
31 }
32
33 public function fileSize(): ?int
34 {
35 return $this->fileSize;
36 }
37
38 public function visibility(): ?string
39 {
40 return $this->visibility;
41 }
42
43 public function lastModified(): ?int
44 {
45 return $this->lastModified;
46 }
47
48 public function mimeType(): ?string
49 {
50 return $this->mimeType;
51 }
52
53 public function extraMetadata(): array
54 {
55 return $this->extraMetadata;
56 }
57
58 public function isFile(): bool
59 {
60 return true;
61 }
62
63 public function isDir(): bool
64 {
65 return false;
66 }
67
68 public function withPath(string $path): self
69 {
70 $clone = clone $this;
71 $clone->path = $path;
72
73 return $clone;
74 }
75
76 public static function fromArray(array $attributes): self
77 {
78 return new FileAttributes(
79 $attributes[StorageAttributes::ATTRIBUTE_PATH],
80 $attributes[StorageAttributes::ATTRIBUTE_FILE_SIZE] ?? null,
81 $attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null,
82 $attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null,
83 $attributes[StorageAttributes::ATTRIBUTE_MIME_TYPE] ?? null,
84 $attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? []
85 );
86 }
87
88 public function jsonSerialize(): array
89 {
90 return [
91 StorageAttributes::ATTRIBUTE_TYPE => self::TYPE_FILE,
92 StorageAttributes::ATTRIBUTE_PATH => $this->path,
93 StorageAttributes::ATTRIBUTE_FILE_SIZE => $this->fileSize,
94 StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility,
95 StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified,
96 StorageAttributes::ATTRIBUTE_MIME_TYPE => $this->mimeType,
97 StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata,
98 ];
99 }
100 }
101