ILIAS  release_7 Revision v7.30-3-g800a261c036
Metadata.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
5
7
16final class Metadata
17{
18
22 private $path;
26 private $type;
27
38 public function __construct(string $path, string $type)
39 {
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}
An exception for terminatinating execution or to throw for unit testing.
Class Metadata This class holds all default metadata send by the filesystem adapters.
Definition: Metadata.php:17
__construct(string $path, string $type)
Metadata constructor.
Definition: Metadata.php:38
getPath()
The path to the file or directory.
Definition: Metadata.php:53
isFile()
The path is a file.
Definition: Metadata.php:87
isDir()
The path is a directory.
Definition: Metadata.php:77
getType()
The type of the subject which can be FILE or DIRECTORY.
Definition: Metadata.php:67
Class MetadataType The possible metadata types of the filesystem metadata.
const FILE
The subject is file.
const DIRECTORY
The subject is a directory.