Skip to content

Commit

Permalink
Finder: completely rewritten
Browse files Browse the repository at this point in the history
- uses generator
- the order of calling the filter() and exclude() methods does not matter
- the in() and from() methods accept the mask
  • Loading branch information
dg committed Feb 2, 2023
1 parent 53615ac commit 58eb1e8
Show file tree
Hide file tree
Showing 12 changed files with 611 additions and 234 deletions.
49 changes: 49 additions & 0 deletions src/Utils/FileInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

declare(strict_types=1);

namespace Nette\Utils;

use Nette;


/**
* Represents the file or directory returned by the Finder.
* @internal do not create instances directly
*/
final class FileInfo extends \SplFileInfo
{
private string $relativePath;


public function __construct(string $file, string $relativePath = '')
{
parent::__construct($file);
$this->setInfoClass(static::class);
$this->relativePath = $relativePath;
}


/**
* Returns the relative directory path.
*/
public function getRelativePath(): string
{
return $this->relativePath;
}


/**
* Returns the relative path including file name.
*/
public function getRelativePathname(): string
{
return ($this->relativePath === '' ? '' : $this->relativePath . DIRECTORY_SEPARATOR)
. $this->getBasename();
}
}
Loading

0 comments on commit 58eb1e8

Please sign in to comment.