ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
Metadata.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
5 
7 
16 final class Metadata
17 {
18 
22  private $path;
26  private $type;
27 
38  public function __construct(string $path, string $type)
39  {
40  if ($type !== MetadataType::FILE && $type !== MetadataType::DIRECTORY) {
41  throw new \InvalidArgumentException("The metadata type must be FILE or DIRECTORY but \"$type\" was given.");
42  }
43 
44  $this->path = $path;
45  $this->type = $type;
46  }
47 
53  public function getPath() : string
54  {
55  return $this->path;
56  }
57 
67  public function getType() : string
68  {
69  return $this->type;
70  }
71 
77  public function isDir() : bool
78  {
79  return (strcmp($this->getType(), MetadataType::DIRECTORY) === 0);
80  }
81 
87  public function isFile() : bool
88  {
89  return (strcmp($this->getType(), MetadataType::FILE) === 0);
90  }
91 }
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:67
__construct(string $path, string $type)
Metadata constructor.
Definition: Metadata.php:38
getPath()
The path to the file or directory.
Definition: Metadata.php:53
const FILE
The subject is file.
isDir()
The path is a directory.
Definition: Metadata.php:77
Class Metadata This class holds all default metadata send by the filesystem adapters.
Definition: Metadata.php:16
isFile()
The path is a file.
Definition: Metadata.php:87
const DIRECTORY
The subject is a directory.