ILIAS  release_8 Revision v8.23
Metadata.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
8 
19 final class Metadata
20 {
21  private string $path;
22  private string $type;
23 
24 
40  public function __construct(string $path, string $type)
41  {
42  if ($type !== MetadataType::FILE && $type !== MetadataType::DIRECTORY) {
43  throw new \InvalidArgumentException("The metadata type must be FILE or DIRECTORY but \"$type\" was given.");
44  }
45 
46  $this->path = $path;
47  $this->type = $type;
48  }
49 
56  public function getPath(): string
57  {
58  return $this->path;
59  }
60 
61 
74  public function getType(): string
75  {
76  return $this->type;
77  }
78 
79 
86  public function isDir(): bool
87  {
88  return (strcmp($this->getType(), MetadataType::DIRECTORY) === 0);
89  }
90 
91 
98  public function isFile(): bool
99  {
100  return (strcmp($this->getType(), MetadataType::FILE) === 0);
101  }
102 }
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:74
__construct(string $path, string $type)
Metadata constructor.
Definition: Metadata.php:40
getPath()
The path to the file or directory.
Definition: Metadata.php:56
const FILE
The subject is file.
isDir()
The path is a directory.
Definition: Metadata.php:86
isFile()
The path is a file.
Definition: Metadata.php:98
const DIRECTORY
The subject is a directory.