PHP Класс FileTextSearch

Usage: It is very easy to use, just look at the example below. To only search for a pattern into the text file, do not define any replacement key. Example: $path = '/path/to/search'; create a class instance $obj = new FileTextSearch(); set the extensions to search files within $obj = setExtensions(array('xml','xsl'); add an extension whenever you need $obj = addExtension('css'); set the pattern to search for $obj = setSearchKey('pattern'); set the replace key if you want to replace matches with it $obj = setReplacementKey('replace'); finally run the search $obj = findReplace($path);
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$m_caseSensitive
$m_fileExtensions
$m_findAllExtensions
$m_isReplaceEnabled
$m_replacementKey
$m_searchKey
$m_totalFound

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

Метод Описание
addExtension ( string $p_extension ) Add a valid search extension.
filePutContents ( string $p_file, mixed $p_data ) : mixed Puts data (after replacement) to given file.
findExtension ( string $p_file ) : mixed Finds the extension for the given file.
findReplace ( string $p_path ) searchDirFiles() wrapper function.
matchedExtension ( string $p_file ) : boolean Checks if a file extension is one the extensions we are going to search.
searchDirFiles ( string $p_path ) : array Runs recursively all into the path.
searchFileData ( string $p_file ) Searches file data and replaces with given pattern.
setExtensions ( array $p_extensions = [] ) Sets extensions to search for.
setReplacementKey ( string $p_replacementKey ) Sets the replacement to replace pattern with.
setSearchKey ( string $p_searchKey, integer $p_caseSensitive ) Sets the pattern and case sensitivity.

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

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

Add a valid search extension.
public addExtension ( string $p_extension )
$p_extension string

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

Puts data (after replacement) to given file.
public filePutContents ( string $p_file, mixed $p_data ) : mixed
$p_file string
$p_data mixed
Результат mixed

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

Finds the extension for the given file.
public findExtension ( string $p_file ) : mixed
$p_file string
Результат mixed the extension on success or NULL on failure

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

searchDirFiles() wrapper function.
public findReplace ( string $p_path )
$p_path string

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

Checks if a file extension is one the extensions we are going to search.
public matchedExtension ( string $p_file ) : boolean
$p_file string
Результат boolean true on success or false on failure

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

Runs recursively all into the path.
public searchDirFiles ( string $p_path ) : array
$p_path string
Результат array

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

Searches file data and replaces with given pattern.
public searchFileData ( string $p_file )
$p_file string

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

Sets extensions to search for.
public setExtensions ( array $p_extensions = [] )
$p_extensions array

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

Sets the replacement to replace pattern with.
public setReplacementKey ( string $p_replacementKey )
$p_replacementKey string

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

Sets the pattern and case sensitivity.
public setSearchKey ( string $p_searchKey, integer $p_caseSensitive )
$p_searchKey string
$p_caseSensitive integer

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

$m_caseSensitive публичное свойство

public $m_caseSensitive

$m_fileExtensions публичное свойство

public $m_fileExtensions

$m_findAllExtensions публичное свойство

public $m_findAllExtensions

$m_isReplaceEnabled публичное свойство

public $m_isReplaceEnabled

$m_replacementKey публичное свойство

public $m_replacementKey

$m_searchKey публичное свойство

public $m_searchKey

$m_totalFound публичное свойство

public $m_totalFound