Skip to content

Commit

Permalink
Added count methods for included dirs or files. (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
siad007 authored Jun 30, 2018
1 parent 046f1de commit 1dec446
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions classes/phing/util/DirectoryScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,15 +715,37 @@ protected function isExcluded($_name)
return false;
}

/**
* Return the count of included files.
*
* @return int
*
* @throws UnexpectedValueException
*/
public function getIncludedFilesCount(): int
{
if ($this->filesIncluded === null) {
throw new UnexpectedValueException('Must call scan() first');
}
return count($this->filesIncluded);
}

/**
* Get the names of the files that matched at least one of the include
* patterns, and matched none of the exclude patterns.
* The names are relative to the basedir.
*
* @return array names of the files
* @throws \UnexpectedValueException
*/
public function getIncludedFiles()
public function getIncludedFiles(): array
{
if ($this->filesIncluded === null) {
throw new UnexpectedValueException('Must call scan() first');
}

sort($this->filesIncluded);

return $this->filesIncluded;
}

Expand Down Expand Up @@ -779,13 +801,35 @@ public function getDeselectedFiles()
* The names are relative to the basedir.
*
* @return array the names of the directories
* @throws \UnexpectedValueException
*/

public function getIncludedDirectories()
{
if ($this->dirsIncluded === null) {
throw new UnexpectedValueException('Must call scan() first');
}

sort($this->dirsIncluded);

return $this->dirsIncluded;
}

/**
* Return the count of included directories.
*
* @return int
*
* @throws UnexpectedValueException
*/
public function getIncludedDirectoriesCount(): int
{
if ($this->dirsIncluded === null) {
throw new UnexpectedValueException('Must call scan() first');
}
return count($this->dirsIncluded);
}

/**
* Get the names of the directories that matched at none of the include
* patterns.
Expand Down Expand Up @@ -870,10 +914,13 @@ public function isEverythingIncluded()
/**
* Tests whether a name should be selected.
*
* @param string $name The filename to check for selecting.
* @param string $file The full file path.
* @param string $name The filename to check for selecting.
* @param string $file The full file path.
* @return boolean False when the selectors says that the file
* should not be selected, True otherwise.
* @throws \BuildException
* @throws \IOException
* @throws NullPointerException
*/
protected function isSelected($name, $file)
{
Expand Down

0 comments on commit 1dec446

Please sign in to comment.