ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Metadata.php
Go to the documentation of this file.
1<?php
2
4
6
17final 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}
An exception for terminatinating execution or to throw for unit testing.
getPath()
The path to the file or directory.
Definition: Metadata.php:69
__construct($path, $type)
Metadata constructor.
Definition: Metadata.php:45
isFile()
The path is a file.
Definition: Metadata.php:111
isDir()
The path is a directory.
Definition: Metadata.php:99
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:87
const FILE
The subject is file.
const DIRECTORY
The subject is a directory.