ExternalParserConfig
in package
Immutable configuration for an external parser loaded from config file.
This value object holds the configuration for a single external parser as defined in config/parsers.php. It is immutable and validated on construction.
Tags
Table of Contents
Constants
- INPUT_MODE_FILE = 'file'
- INPUT_MODE_STDIN = 'stdin'
- OUTPUT_FORMAT_LINE = 'line'
- OUTPUT_FORMAT_WAKATI = 'wakati'
- VALID_INPUT_MODES = [self::INPUT_MODE_STDIN, self::INPUT_MODE_FILE]
- VALID_OUTPUT_FORMATS = [self::OUTPUT_FORMAT_LINE, self::OUTPUT_FORMAT_WAKATI]
Properties
- $args : array<string|int, mixed>
- $binary : string
- $inputMode : string
- $name : string
- $outputFormat : string
- $type : string
Methods
- __construct() : mixed
- Create a new external parser configuration.
- fromArray() : self
- Create configuration from a config array.
- getArgs() : array<string|int, string>
- Get the command-line arguments.
- getBinary() : string
- Get the path to the executable.
- getInputMode() : string
- Get the input mode.
- getName() : string
- Get the human-readable display name.
- getOutputFormat() : string
- Get the output format.
- getType() : string
- Get the unique parser type identifier.
- usesFile() : bool
- Check if input is passed via temporary file.
- usesStdin() : bool
- Check if input is passed via stdin.
- validate() : void
- Validate the configuration values.
Constants
INPUT_MODE_FILE
public
mixed
INPUT_MODE_FILE
= 'file'
INPUT_MODE_STDIN
public
mixed
INPUT_MODE_STDIN
= 'stdin'
OUTPUT_FORMAT_LINE
public
mixed
OUTPUT_FORMAT_LINE
= 'line'
OUTPUT_FORMAT_WAKATI
public
mixed
OUTPUT_FORMAT_WAKATI
= 'wakati'
VALID_INPUT_MODES
private
mixed
VALID_INPUT_MODES
= [self::INPUT_MODE_STDIN, self::INPUT_MODE_FILE]
VALID_OUTPUT_FORMATS
private
mixed
VALID_OUTPUT_FORMATS
= [self::OUTPUT_FORMAT_LINE, self::OUTPUT_FORMAT_WAKATI]
Properties
$args
private
array<string|int, mixed>
$args
$binary
private
string
$binary
$inputMode
private
string
$inputMode
$name
private
string
$name
$outputFormat
private
string
$outputFormat
$type
private
string
$type
Methods
__construct()
Create a new external parser configuration.
public
__construct(string $type, string $name, string $binary, array<string|int, string> $args, string $inputMode, string $outputFormat) : mixed
Parameters
- $type : string
-
Unique parser type identifier (e.g., 'jieba')
- $name : string
-
Human-readable display name
- $binary : string
-
Path to executable or command name
- $args : array<string|int, string>
-
Command-line arguments
- $inputMode : string
-
How input is passed: 'stdin' or 'file'
- $outputFormat : string
-
Output format: 'line' or 'wakati'
Tags
fromArray()
Create configuration from a config array.
public
static fromArray(string $type, array<string, mixed> $config) : self
Parameters
- $type : string
-
Parser type identifier
- $config : array<string, mixed>
-
Configuration array from config file
Tags
Return values
self —Parser configuration
getArgs()
Get the command-line arguments.
public
getArgs() : array<string|int, string>
Return values
array<string|int, string> —Arguments to pass to the binary
getBinary()
Get the path to the executable.
public
getBinary() : string
Return values
string —Absolute path or command name
getInputMode()
Get the input mode.
public
getInputMode() : string
Return values
string —'stdin' or 'file'
getName()
Get the human-readable display name.
public
getName() : string
Return values
string —Display name for UI
getOutputFormat()
Get the output format.
public
getOutputFormat() : string
Return values
string —'line' or 'wakati'
getType()
Get the unique parser type identifier.
public
getType() : string
Return values
string —Parser type (e.g., 'jieba', 'sudachi')
usesFile()
Check if input is passed via temporary file.
public
usesFile() : bool
Return values
bool —True if input mode is file
usesStdin()
Check if input is passed via stdin.
public
usesStdin() : bool
Return values
bool —True if input mode is stdin
validate()
Validate the configuration values.
private
validate() : void