path = \rtrim($path, '/\\'); $this->name = \basename($path); $this->createdAt = new \DateTime('now'); $this->changedAt = new \DateTime('now'); } /** * {@inheritdoc} */ public function getCount(bool $recursive = true) : int { return $this->count; } /** * {@inheritdoc} */ public function getSize(bool $recursive = true) : int { return $this->size; } /** * {@inheritdoc} */ public function getName() : string { return $this->name; } /** * {@inheritdoc} */ public function getPath() : string { return $this->path; } /** * {@inheritdoc} */ public function parentNode() : Directory { return new Directory(Directory::parent($this->path)); } /** * {@inheritdoc} */ public function getCreatedAt() : \DateTime { return $this->createdAt; } /** * {@inheritdoc} */ public function getChangedAt() : \DateTime { return $this->changedAt; } /** * {@inheritdoc} */ public function getOwner() : int { return $this->owner; } /** * {@inheritdoc} */ public function getPermission() : int { return $this->permission; } /** * {@inheritdoc} */ public function index() : void { $mtime = \filemtime($this->path); $ctime = \filectime($this->path); $this->createdAt->setTimestamp($mtime === false ? 0 : $mtime); $this->changedAt->setTimestamp($ctime === false ? 0 : $ctime); $owner = \fileowner($this->path); $this->owner = $owner === false ? 0 : $owner; $this->permission = (int) \substr(\sprintf('%o', \fileperms($this->path)), -4); } }