ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Metadata.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
5 
7 
18 final class Metadata
19 {
20 
24  private $path;
28  private $type;
29 
30 
46  public function __construct(string $path, string $type)
47  {
48  if ($type !== MetadataType::FILE && $type !== MetadataType::DIRECTORY) {
49  throw new \InvalidArgumentException("The metadata type must be FILE or DIRECTORY but \"$type\" was given.");
50  }
51 
52  $this->path = $path;
53  $this->type = $type;
54  }
55 
62  public function getPath() : string
63  {
64  return $this->path;
65  }
66 
67 
80  public function getType() : string
81  {
82  return $this->type;
83  }
84 
85 
92  public function isDir() : bool
93  {
94  return (strcmp($this->getType(), MetadataType::DIRECTORY) === 0);
95  }
96 
97 
104  public function isFile() : bool
105  {
106  return (strcmp($this->getType(), MetadataType::FILE) === 0);
107  }
108 }
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:80
__construct(string $path, string $type)
Metadata constructor.
Definition: Metadata.php:46
getPath()
The path to the file or directory.
Definition: Metadata.php:62
const FILE
The subject is file.
isDir()
The path is a directory.
Definition: Metadata.php:92
isFile()
The path is a file.
Definition: Metadata.php:104
const DIRECTORY
The subject is a directory.