FileAccess Orion

PhpExtractor extends AbstractFileExtractor
in package
implements ExtractorInterface

PhpExtractor extracts translation messages from a PHP template.

Tags
author

Michel Salib michelsalib@hotmail.com

Interfaces, Classes, Traits and Enums

ExtractorInterface
Extracts translation messages from a directory or files to the catalogue.

Table of Contents

DOMAIN_TOKEN  = 1001
MESSAGE_TOKEN  = 300
METHOD_ARGUMENTS_TOKEN  = 1000
$sequences  : array<string|int, mixed>
The sequence that captures translation messages.
$prefix  : string
Prefix for new found message.
extract()  : mixed
Extracts translation messages from files, a file or a directory to the catalogue.
setPrefix()  : mixed
Sets the prefix that should be used for new found messages.
canBeExtracted()  : bool
extractFiles()  : iteratable<string|int, mixed>
extractFromDirectory()  : iteratable<string|int, mixed>
isFile()  : bool
normalizeToken()  : string|null
Normalizes a token.
parseTokens()  : mixed
Extracts trans message from PHP tokens.
getValue()  : mixed
Extracts the message from the iterator while the tokens match allowed message tokens.
seekToNextRelevantToken()  : mixed
Seeks to a non-whitespace token.
skipMethodArgument()  : mixed
toSplFileInfo()  : SplFileInfo

Constants

METHOD_ARGUMENTS_TOKEN

public mixed METHOD_ARGUMENTS_TOKEN = 1000

Properties

$sequences

The sequence that captures translation messages.

protected array<string|int, mixed> $sequences = [['->', 'trans', '(', self::MESSAGE_TOKEN, ',', self::METHOD_ARGUMENTS_TOKEN, ',', self::DOMAIN_TOKEN], ['->', 'transChoice', '(', self::MESSAGE_TOKEN, ',', self::METHOD_ARGUMENTS_TOKEN, ',', self::METHOD_ARGUMENTS_TOKEN, ',', self::DOMAIN_TOKEN], ['->', 'trans', '(', self::MESSAGE_TOKEN], ['->', 'transChoice', '(', self::MESSAGE_TOKEN]]

$prefix

Prefix for new found message.

private string $prefix = ''

Methods

extract()

Extracts translation messages from files, a file or a directory to the catalogue.

public extract(mixed $resource, MessageCatalogue $catalog) : mixed
Parameters
$resource : mixed

Files, a file or a directory

$catalog : MessageCatalogue
Return values
mixed

setPrefix()

Sets the prefix that should be used for new found messages.

public setPrefix(mixed $prefix) : mixed
Parameters
$prefix : mixed

The prefix

Return values
mixed

canBeExtracted()

protected canBeExtracted(string $file) : bool
Parameters
$file : string
Tags
throws
InvalidArgumentException
Return values
bool

extractFiles()

protected extractFiles(string|iteratable<string|int, mixed> $resource) : iteratable<string|int, mixed>
Parameters
$resource : string|iteratable<string|int, mixed>

Files, a file or a directory

Return values
iteratable<string|int, mixed>

extractFromDirectory()

protected extractFromDirectory(mixed $directory) : iteratable<string|int, mixed>
Parameters
$directory : mixed
Return values
iteratable<string|int, mixed>

files to be extracted

normalizeToken()

Normalizes a token.

protected normalizeToken(mixed $token) : string|null
Parameters
$token : mixed
Return values
string|null

parseTokens()

Extracts trans message from PHP tokens.

protected parseTokens(array<string|int, mixed> $tokens, MessageCatalogue $catalog) : mixed
Parameters
$tokens : array<string|int, mixed>
$catalog : MessageCatalogue
Return values
mixed

getValue()

Extracts the message from the iterator while the tokens match allowed message tokens.

private getValue(Iterator $tokenIterator) : mixed
Parameters
$tokenIterator : Iterator
Return values
mixed

seekToNextRelevantToken()

Seeks to a non-whitespace token.

private seekToNextRelevantToken(Iterator $tokenIterator) : mixed
Parameters
$tokenIterator : Iterator
Return values
mixed

skipMethodArgument()

private skipMethodArgument(Iterator $tokenIterator) : mixed
Parameters
$tokenIterator : Iterator
Return values
mixed

toSplFileInfo()

private toSplFileInfo(string $file) : SplFileInfo
Parameters
$file : string
Return values
SplFileInfo

Search results