| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace League\Flysystem;
|
|
|
6 |
|
|
|
7 |
use RuntimeException;
|
|
|
8 |
use Throwable;
|
|
|
9 |
|
|
|
10 |
final class UnableToRetrieveMetadata extends RuntimeException implements FilesystemOperationFailed
|
|
|
11 |
{
|
|
|
12 |
/**
|
|
|
13 |
* @var string
|
|
|
14 |
*/
|
|
|
15 |
private $location;
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* @var string
|
|
|
19 |
*/
|
|
|
20 |
private $metadataType;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* @var string
|
|
|
24 |
*/
|
|
|
25 |
private $reason;
|
|
|
26 |
|
|
|
27 |
public static function lastModified(string $location, string $reason = '', Throwable $previous = null): self
|
|
|
28 |
{
|
|
|
29 |
return static::create($location, FileAttributes::ATTRIBUTE_LAST_MODIFIED, $reason, $previous);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public static function visibility(string $location, string $reason = '', Throwable $previous = null): self
|
|
|
33 |
{
|
|
|
34 |
return static::create($location, FileAttributes::ATTRIBUTE_VISIBILITY, $reason, $previous);
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
public static function fileSize(string $location, string $reason = '', Throwable $previous = null): self
|
|
|
38 |
{
|
|
|
39 |
return static::create($location, FileAttributes::ATTRIBUTE_FILE_SIZE, $reason, $previous);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public static function mimeType(string $location, string $reason = '', Throwable $previous = null): self
|
|
|
43 |
{
|
|
|
44 |
return static::create($location, FileAttributes::ATTRIBUTE_MIME_TYPE, $reason, $previous);
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public static function create(string $location, string $type, string $reason = '', Throwable $previous = null): self
|
|
|
48 |
{
|
|
|
49 |
$e = new static("Unable to retrieve the $type for file at location: $location. {$reason}", 0, $previous);
|
|
|
50 |
$e->reason = $reason;
|
|
|
51 |
$e->location = $location;
|
|
|
52 |
$e->metadataType = $type;
|
|
|
53 |
|
|
|
54 |
return $e;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
public function reason(): string
|
|
|
58 |
{
|
|
|
59 |
return $this->reason;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public function location(): string
|
|
|
63 |
{
|
|
|
64 |
return $this->location;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public function metadataType(): string
|
|
|
68 |
{
|
|
|
69 |
return $this->metadataType;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
public function operation(): string
|
|
|
73 |
{
|
|
|
74 |
return FilesystemOperationFailed::OPERATION_RETRIEVE_METADATA;
|
|
|
75 |
}
|
|
|
76 |
}
|