Settings for specifying a chunk of a text file.

Chunk specifications are used by a \FeaturePhp\Generator\ChunkGenerator to specify a chunk of text for inclusion in a \FeaturePhp\File\ChunkFile. The chunk specification settings inside an artifact's generator settings hold a specific chunk of a chunk file and follow the structure:

  • root (object)
    • target (string) - the file target in the generated product
    • text (string) - a chunk of text to include in the target

The chunk specification settings in the product line's generator settings hold general settings for a chunk file and follow the structure:

  • root (object)
    • target (string) - the file target in the generated product
    • header (string) - header before all chunks
    • footer (string) - footer after all chunks
    • newline (bool) - whether to include new line characters after each chunk
package Default
inherited_from \FeaturePhp\Specification\ExtendSpecification

 Methods

Creates a chunk specification.

__construct(array $cfg, string $directory = ".", \FeaturePhp\Artifact\Artifact $artifact = null

The directory may be used to resolve relative paths in the settings.

inherited_from \FeaturePhp\Specification\ExtendSpecification::__construct()

Parameters

$cfg

array

a plain settings array

$directory

string

the directory the settings apply to

$artifact

\FeaturePhp\Artifact\Artifact

Creates settings.

__construct(array $cfg, string $directory = "."
Inherited

The directory may be used to resolve relative paths in the settings.

Parameters

$cfg

array

a plain settings array

$directory

string

the directory the settings apply to

Creates settings.

fromArray(array $cfg, string $directory = "."
InheritedStatic

Parameters

$cfg

array

a plain settings array

$directory

string

the directory the settings apply to

Creates a chunk specification from a plain settings array.

fromArrayAndSettings(array $cfg, \FeaturePhp\Settings $settings, \FeaturePhp\Artifact\Artifact $artifact = null) : \FeaturePhp\Specification\ChunkSpecification
Static

The settings context is taken into consideration to generate paths relative to the settings.

Parameters

$cfg

array

a plain settings array

$settings

\FeaturePhp\Settings

the settings context

$artifact

\FeaturePhp\Artifact\Artifact

is ignored

Returns

\FeaturePhp\Specification\ChunkSpecification

Creates a file specification from a plain settings array.

fromArrayAndSettings(array $cfg, \FeaturePhp\Settings $settings, \FeaturePhp\Artifact\Artifact $artifact = null) : \FeaturePhp\Specification\FileSpecification
InheritedStatic

The settings context is taken into consideration to generate paths relative to the settings.

Parameters

$cfg

array

a plain settings array

$settings

\FeaturePhp\Settings

the settings context

$artifact

\FeaturePhp\Artifact\Artifact

Returns

\FeaturePhp\Specification\FileSpecification

Creates settings from a JSON-encoded file.

fromFile(string $fileName) : \FeaturePhp\Settings
InheritedStatic

Parameters

$fileName

string

Returns

\FeaturePhp\Settings

Creates settings from a JSON-encoded string.

fromString(string $json, string $directory = ".") : \FeaturePhp\Settings
InheritedStatic

Parameters

$json

string

$directory

string

the directory the settings apply to

Returns

\FeaturePhp\Settings

Returns a setting.

get() : mixed
Inherited

A setting path can be supplied variadically.

Returns

mixed

Returns the settings' directory.

getDirectory() : string
Inherited

Returns

string

Returns the chunked file's footer.

getFooter() : string

Returns

string

Returns the chunked file's header.

getHeader() : string

Returns

string

Returns a setting in a plain settings array.

getIn(array $cfg) : mixed
Inherited

A setting path can be supplied variadically.

Parameters

$cfg

array

Returns

mixed

Creates an instance of a class from a plain settings array.

getInstance(string|array|boolean $object, string $klass) : \FeaturePhp\$class
Inherited

If a string is given, the class is instantiated from a file. If an array("data" => ...) is given, the class is instantiated from a string. If another array is given, the class is instantiated from that array. If true is given, the class is instantiated from an empty array.

Parameters

$object

stringarrayboolean

$klass

string

Returns

\FeaturePhp\$class

Returns whether to include new line characters after each chunk.

getNewline() : boolean

Returns

boolean

Returns an optional setting, defaulting to a value.

getOptional(mixed $defaultValue) : mixed
Inherited

A setting path can be supplied variadically.

Parameters

$defaultValue

mixed

Returns

mixed

Returns a path in the context of the settings' directory.

getPath(string $path) : string
Inherited

Parameters

$path

string

Returns

string

Returns the entity's source relative to its settings.

getRelativeSource() : string
Inherited

Returns

string

Returns the entity's source.

getSource() : string
Inherited

Returns

string

Returns the entity's source place.

getSourcePlace() : \FeaturePhp\Artifact\Place
Inherited

Returns

\FeaturePhp\Artifact\Place

Returns the entity's target.

getTarget() : string
Inherited

Returns

string

Returns the entity's target place.

getTargetPlace() : \FeaturePhp\Artifact\Place
Inherited

Returns

\FeaturePhp\Artifact\Place

Returns the chunk's text.

getText() : string

Returns

string

Returns a setting if a predicate is satisfied.

getWith(string $key, callable $predicate) : mixed
Inherited

Throws \FeaturePhp\InvalidSettingsException if the predicate fails.

Parameters

$key

string

$predicate

callable

Returns

mixed

Creates empty settings in the context of a directory.

inDirectory(string $directory) 
InheritedStatic

Parameters

$directory

string

the directory the settings apply to

Returns whether the specification may create its specified file.

mayCreate() : string
Inherited

Returns

string

Returns whether a plain settings array has a key.

has(string $key, array $cfg = null) : boolean
Inherited

If no settings array is given, the internal settings array is assumed.

Parameters

$key

string

$cfg

array

Returns

boolean

Sets a setting.

set(string $key, mixed $value) 
Inherited

A setting path can be supplied variadically.

Parameters

$key

string

$value

mixed

Sets a setting if it is not already set.

setOptional(string $key, mixed $value) 
Inherited

Parameters

$key

string

$value

mixed

Returns a setting in a plain settings array.

_get(array $cfg) : mixed
Inherited

A setting path can be supplied variadically.

Parameters

$cfg

array

Returns

mixed

Sets a setting in a plain settings array.

_set(array $cfg, array $args) 
Inherited

Parameters

$cfg

array

$args

array

a setting path followed by the setting's new value

 Properties

 

the internal plain settings array

$cfg : array

Default