ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Metadata.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
5
7
18final class Metadata
19{
20
24 private $path;
28 private $type;
29
30
46 public function __construct(string $path, string $type)
47 {
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}
An exception for terminatinating execution or to throw for unit testing.
__construct(string $path, string $type)
Metadata constructor.
Definition: Metadata.php:46
getPath()
The path to the file or directory.
Definition: Metadata.php:62
isFile()
The path is a file.
Definition: Metadata.php:104
isDir()
The path is a directory.
Definition: Metadata.php:92
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:80
const FILE
The subject is file.
const DIRECTORY
The subject is a directory.