PHP 클래스 Spyc

This class can be used to read a YAML file and convert its contents into a PHP array. It currently supports a very limited subsection of the YAML spec. Usage: $parser = new Spyc; $array = $parser->load($file);
파일 보기 프로젝트 열기: mustangostang/spyc 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_nodeId
$setting_dump_force_quotes boolean Setting this to true will force YAMLDump to enclose any string value in quotes. False by default.
$setting_use_syck_is_possible boolean Setting this to true will forse YAMLLoad to use syck_load function when possible. False by default.

공개 메소드들

메소드 설명
YAMLDump ( array $array, integer $indent = false, integer $wordwrap = false, integer $no_opening_dashes = false ) : string Dump YAML from PHP array statically
YAMLLoad ( string $input ) : array Load YAML into a PHP array statically
YAMLLoadString ( string $input ) : array Load a string of YAML into a PHP array statically
dump ( array $array, integer $indent = false, integer $wordwrap = false, $no_opening_dashes = false ) : string Dump PHP array to YAML
load ( string $input ) : array Load a valid YAML string to Spyc.
loadFile ( string $file ) : array Load a valid YAML file to Spyc.
revertLiteralPlaceHolder ( $lineArray, $literalBlock )

비공개 메소드들

메소드 설명
__load ( $input ) LOADING FUNCTIONS
__loadString ( $input )
_doFolding ( $value, $indent ) : string Folds a string of text, if necessary
_doLiteralBlock ( $value, $indent ) : string Creates a literal block for dumping
_dumpNode ( $key, $value, $indent, $previous_key, $first_key, $source_array = null ) : string Returns YAML from a key and a value
_inlineEscape ( $inline ) : array Used in inlines to check for more inlines or quoted strings
_parseLine ( string $line ) : array Parses YAML code and returns an array for a node
_toType ( string $value ) : mixed Finds the type of the passed value, returns the value as the new type.
_yamlize ( $key, $value, $indent, $previous_key, $first_key, $source_array = null ) : string Attempts to convert a key / value array item to YAML
_yamlizeArray ( $array, $indent ) : string Attempts to convert an array to YAML
addArray ( $incoming_data, $incoming_indent )
addArrayInline ( $array, $indent )
addGroup ( $line, $group )
addLiteralLine ( $literalBlock, $line, $literalBlockStyle, $indent )
checkKeysInValue ( $value )
clearBiggerPathValues ( $indent )
coerceValue ( &$value ) Coerce a string into a native type Reference: http://yaml.org/type/bool.html TODO: Use only words from the YAML spec.
getParentPathByIndent ( $indent )
getTranslations ( array $words ) Given a set of words, perform the appropriate translations on them to match the YAML 1.1 specification for type coercing.
greedilyNeedNextLine ( $line )
isArrayElement ( $line )
isComment ( $line )
isEmpty ( $line )
isFalseWord ( $value )
isHashElement ( $line )
isLiteral ( $line )
isNullWord ( $value )
isPlainArray ( $line )
isTranslationWord ( $value )
isTrueWord ( $value )
literalBlockContinues ( $line, $lineIndent )
loadFromSource ( $input )
loadFromString ( $input )
loadWithSource ( $Source )
nodeContainsGroup ( $line )
referenceContentsByAlias ( $alias )
returnArrayElement ( $line )
returnKeyValuePair ( $line )
returnMappedSequence ( $line )
returnMappedValue ( $line )
returnPlainArray ( $line )
startsLiteralBlock ( $line )
startsMappedSequence ( $line )
startsMappedValue ( $line )
stripGroup ( $line, $group )
stripIndent ( $line, $indent )
unquote ( $value )

메소드 상세

YAMLDump() 공개 정적인 메소드

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as nothing.yaml and pass it around. Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default. Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.
public static YAMLDump ( array $array, integer $indent = false, integer $wordwrap = false, integer $no_opening_dashes = false ) : string
$array array PHP array
$indent integer Pass in false to use the default, which is 2
$wordwrap integer Pass in 0 for no wordwrap, false for default (40)
$no_opening_dashes integer Do not start YAML file with "---\n"
리턴 string

YAMLLoad() 공개 정적인 메소드

The load method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array. Pretty simple. Usage: $array = Spyc::YAMLLoad('lucky.yaml'); print_r($array);
public static YAMLLoad ( string $input ) : array
$input string Path of YAML file or string containing YAML
리턴 array

YAMLLoadString() 공개 정적인 메소드

The load method, when supplied with a YAML string, will do its best to convert YAML in a string into a PHP array. Pretty simple. Note: use this function if you don't want files from the file system loaded and processed as YAML. This is of interest to people concerned about security whose input is from a string. Usage: $array = Spyc::YAMLLoadString("---\n0: hello world\n"); print_r($array);
public static YAMLLoadString ( string $input ) : array
$input string String containing YAML
리턴 array

dump() 공개 메소드

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as tasteful.yaml and pass it around. Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default. Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.
public dump ( array $array, integer $indent = false, integer $wordwrap = false, $no_opening_dashes = false ) : string
$array array PHP array
$indent integer Pass in false to use the default, which is 2
$wordwrap integer Pass in 0 for no wordwrap, false for default (40)
리턴 string

load() 공개 메소드

Load a valid YAML string to Spyc.
public load ( string $input ) : array
$input string
리턴 array

loadFile() 공개 메소드

Load a valid YAML file to Spyc.
public loadFile ( string $file ) : array
$file string
리턴 array

revertLiteralPlaceHolder() 공개 메소드

public revertLiteralPlaceHolder ( $lineArray, $literalBlock )

프로퍼티 상세

$_nodeId 공개적으로 프로퍼티

public $_nodeId

$setting_dump_force_quotes 공개적으로 프로퍼티

Setting this to true will force YAMLDump to enclose any string value in quotes. False by default.
public bool $setting_dump_force_quotes
리턴 boolean

$setting_use_syck_is_possible 공개적으로 프로퍼티

Setting this to true will forse YAMLLoad to use syck_load function when possible. False by default.
public bool $setting_use_syck_is_possible
리턴 boolean