ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Metadata.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
21 
23 
31 final class Metadata
32 {
33  private string $type;
34 
50  public function __construct(private string $path, string $type)
51  {
52  if ($type !== MetadataType::FILE && $type !== MetadataType::DIRECTORY) {
53  throw new \InvalidArgumentException("The metadata type must be FILE or DIRECTORY but \"$type\" was given.");
54  }
55  $this->type = $type;
56  }
57 
62  public function getPath(): string
63  {
64  return $this->path;
65  }
66 
76  public function getType(): string
77  {
78  return $this->type;
79  }
80 
85  public function isDir(): bool
86  {
87  return (strcmp($this->getType(), MetadataType::DIRECTORY) === 0);
88  }
89 
94  public function isFile(): bool
95  {
96  return (strcmp($this->getType(), MetadataType::FILE) === 0);
97  }
98 }
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:76
__construct(private string $path, string $type)
Metadata constructor.
Definition: Metadata.php:50
getPath()
The path to the file or directory.
Definition: Metadata.php:62
const FILE
The subject is file.
$path
Definition: ltiservices.php:29
isDir()
The path is a directory.
Definition: Metadata.php:85
isFile()
The path is a file.
Definition: Metadata.php:94
const DIRECTORY
The subject is a directory.