ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Metadata.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
17 final class Metadata
18 {
19 
23  private $path;
27  private $type;
28 
29 
45  public function __construct($path, $type)
46  {
47  if (!is_string($path)) {
48  throw new \InvalidArgumentException("Path must be of type string.");
49  }
50 
51  if (!is_string($type)) {
52  throw new \InvalidArgumentException("Type must be of type string.");
53  }
54 
56  throw new \InvalidArgumentException("The metadata type must be FILE or DIRECTORY but \"$type\" was given.");
57  }
58 
59  $this->path = $path;
60  $this->type = $type;
61  }
62 
69  public function getPath()
70  {
71  return $this->path;
72  }
73 
74 
87  public function getType()
88  {
89  return $this->type;
90  }
91 
92 
99  public function isDir()
100  {
101  return (strcmp($this->getType(), MetadataType::DIRECTORY) === 0);
102  }
103 
104 
111  public function isFile()
112  {
113  return (strcmp($this->getType(), MetadataType::FILE) === 0);
114  }
115 }
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:87
getPath()
The path to the file or directory.
Definition: Metadata.php:69
const FILE
The subject is file.
__construct($path, $type)
Metadata constructor.
Definition: Metadata.php:45
isDir()
The path is a directory.
Definition: Metadata.php:99
isFile()
The path is a file.
Definition: Metadata.php:111
const DIRECTORY
The subject is a directory.