PHP Класс PHPExiftool\Reader

It scans files and directories, and provide an iterator on the FileEntities generated based on the results. Example usage: $Reader = new Reader(); $Reader->in('/path/to/directory') ->exclude('tests') ->extensions(array('jpg', 'xml)); Throws an exception if no file found $first = $Reader->first(); Returns null if no file found $first = $Reader->getOneOrNull(); foreach($Reader as $entity) { Do your logic with FileEntity }
Автор: Romain Neutron ([email protected])
Наследование: implements IteratorAggregate
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$collection Doctrine\Common\Collections\ArrayCollection
$dirs
$excludeDirs
$exiftool
$extensions
$extensionsToggle
$files
$followSymLinks
$ignoreDotFile
$parser
$readers
$recursive
$sort

Открытые методы

Метод Описание
__construct ( Exiftool $exiftool, RDFParser $parser ) Constructor
__destruct ( )
all ( ) : ArrayCollection Perform the scan and returns all the results
append ( Reader $reader ) : Reader Append a reader to this one.
create ( Psr\Log\LoggerInterface $logger )
exclude ( string | array $dirs ) : Reader Exclude directories from scan
extensions ( string | array $extensions, boolean $restrict = true ) : Reader Restrict / Discard files based on extensions Extensions are case insensitive
files ( string | array $files ) : Reader Add files to scan
first ( ) : FileEntity Return the first result. If no result available, throws an exception
followSymLinks ( ) : Reader Toggle to enable follow Symbolic Links
getIterator ( ) : Iterator Implements \IteratorAggregate Interface
getOneOrNull ( ) : FileEntity Return the first result. If no result available, null is returned
ignoreDotFiles ( ) : Reader Ignore files starting with a dot (.)
in ( string | array $dirs ) : Reader Add dirs to scan
notRecursive ( ) : Reader Disable recursivity in directories scan.
reset ( )
sort ( string | array $by ) : Reader Sort results with one or many criteria

Защищенные методы

Метод Описание
buildQuery ( ) : string Build query from criterias
buildQueryAndExecute ( ) : ArrayCollection Build the command returns an ArrayCollection of FileEntity
computeExcludeDirs ( string $rawExcludeDirs, $rawSearchDirs ) : array Compute raw exclude rules to simple ones, based on exclude dirs and search dirs
resetResults ( ) : Reader Reset any computed result

Описание методов

__construct() публичный Метод

Constructor
public __construct ( Exiftool $exiftool, RDFParser $parser )
$exiftool Exiftool
$parser RDFParser

__destruct() публичный Метод

public __destruct ( )

all() публичный Метод

Perform the scan and returns all the results
public all ( ) : ArrayCollection
Результат Doctrine\Common\Collections\ArrayCollection

append() публичный Метод

Finale result will be the sum of the current reader and all appended ones.
public append ( Reader $reader ) : Reader
$reader Reader The reader to append
Результат Reader

buildQuery() защищенный Метод

Build query from criterias
protected buildQuery ( ) : string
Результат string

buildQueryAndExecute() защищенный Метод

Build the command returns an ArrayCollection of FileEntity
protected buildQueryAndExecute ( ) : ArrayCollection
Результат Doctrine\Common\Collections\ArrayCollection

computeExcludeDirs() защищенный Метод

Compute raw exclude rules to simple ones, based on exclude dirs and search dirs
protected computeExcludeDirs ( string $rawExcludeDirs, $rawSearchDirs ) : array
$rawExcludeDirs string
Результат array

create() публичный статический Метод

public static create ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

exclude() публичный Метод

Warning: only first depth directories can be excluded Imagine a directory structure like below, With a scan in "root", only sub1 or sub2 can be excluded, not subsub. root ├── sub1 └── sub2    └── subsub Example usage: Will scan documents recursively, discarding documents/test $Reader ->in('documents') ->exclude(array('test'))
public exclude ( string | array $dirs ) : Reader
$dirs string | array The directories
Результат Reader

extensions() публичный Метод

Restrict / Discard files based on extensions Extensions are case insensitive
public extensions ( string | array $extensions, boolean $restrict = true ) : Reader
$extensions string | array The list of extension
$restrict boolean Toggle restrict/discard method
Результат Reader

files() публичный Метод

Example usage: Will scan 3 files : dc00.jpg in CWD and absolute paths /tmp/image.jpg and /tmp/raw.CR2 $Reader ->files('dc00.jpg') ->files(array('/tmp/image.jpg', '/tmp/raw.CR2'))
public files ( string | array $files ) : Reader
$files string | array The files
Результат Reader

first() публичный Метод

Return the first result. If no result available, throws an exception
public first ( ) : FileEntity
Результат FileEntity

getIterator() публичный Метод

Implements \IteratorAggregate Interface
public getIterator ( ) : Iterator
Результат Iterator

getOneOrNull() публичный Метод

Return the first result. If no result available, null is returned
public getOneOrNull ( ) : FileEntity
Результат FileEntity

ignoreDotFiles() публичный Метод

Folders starting with a dot are always exluded due to exiftool behaviour. You should include them manually
public ignoreDotFiles ( ) : Reader
Результат Reader

in() публичный Метод

Example usage: Will scan 3 dirs : documents in CWD and absolute paths /usr and /var $Reader ->in('documents') ->in(array('/tmp', '/var'))
public in ( string | array $dirs ) : Reader
$dirs string | array The directories
Результат Reader

notRecursive() публичный Метод

If you only specify files, this toggle has no effect
public notRecursive ( ) : Reader
Результат Reader

reset() публичный Метод

public reset ( )

resetResults() защищенный Метод

Reset any computed result
protected resetResults ( ) : Reader
Результат Reader

sort() публичный Метод

Example usage: Will sort by directory then filename $Reader ->in('documents') ->sort(array('directory', 'filename')) Will sort by filename $Reader ->in('documents') ->sort('filename')
public sort ( string | array $by ) : Reader
$by string | array
Результат Reader

Описание свойств

$collection защищенное свойство

protected ArrayCollection,Doctrine\Common\Collections $collection
Результат Doctrine\Common\Collections\ArrayCollection

$dirs защищенное свойство

protected $dirs

$excludeDirs защищенное свойство

protected $excludeDirs

$exiftool защищенное свойство

protected $exiftool

$extensions защищенное свойство

protected $extensions

$extensionsToggle защищенное свойство

protected $extensionsToggle

$files защищенное свойство

protected $files

$ignoreDotFile защищенное свойство

protected $ignoreDotFile

$parser защищенное свойство

protected $parser

$readers защищенное свойство

protected $readers

$recursive защищенное свойство

protected $recursive

$sort защищенное свойство

protected $sort