PHP 클래스 Format

파일 보기 프로젝트 열기: chriskacerguis/codeigniter-restserver 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_data mixed Data to parse
$_from_type string Type to convert from

공개 메소드들

메소드 설명
__construct ( null $data = NULL, null $from_type = NULL ) DO NOT CALL THIS DIRECTLY, USE factory()
factory ( mixed $data, string $from_type = NULL ) : object Create an instance of the format class e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv();
to_array ( mixed | null $data = NULL ) : array Format data as an array
to_csv ( mixed | null $data = NULL, string $delimiter = ',', string $enclosure = '"' ) : string
to_html ( mixed | null $data = NULL ) : mixed Format data as HTML
to_json ( mixed | null $data = NULL ) : string Encode data as json
to_php ( mixed | null $data = NULL ) : mixed Format data using a PHP structure
to_serialized ( mixed | null $data = NULL ) : string Encode data as a serialized array
to_xml ( mixed | null $data = NULL, null $structure = NULL, string $basenode = 'xml' ) : mixed Format data as XML

보호된 메소드들

메소드 설명
_from_csv ( string $data, string $delimiter = ',', string $enclosure = '"' ) : array
_from_json ( string $data ) : mixed
_from_php ( string $data ) : string
_from_serialize ( string $data ) : mixed
_from_xml ( string $data ) : array

메소드 상세

__construct() 공개 메소드

DO NOT CALL THIS DIRECTLY, USE factory()
public __construct ( null $data = NULL, null $from_type = NULL )
$data null
$from_type null

_from_csv() 보호된 메소드

protected _from_csv ( string $data, string $delimiter = ',', string $enclosure = '"' ) : array
$data string CSV string
$delimiter string The optional delimiter parameter sets the field delimiter (one character only). NULL will use the default value (,)
$enclosure string The optional enclosure parameter sets the field enclosure (one character only). NULL will use the default value (")
리턴 array A multi-dimensional array with the outer array being the number of rows and the inner arrays the individual fields

_from_json() 보호된 메소드

protected _from_json ( string $data ) : mixed
$data string Encoded json string
리턴 mixed Decoded json string with leading and trailing whitespace removed

_from_php() 보호된 메소드

protected _from_php ( string $data ) : string
$data string Data to trim leading and trailing whitespace
리턴 string Data with leading and trailing whitespace removed

_from_serialize() 보호된 메소드

protected _from_serialize ( string $data ) : mixed
$data string Data to unserialize
리턴 mixed Unserialized data

_from_xml() 보호된 메소드

protected _from_xml ( string $data ) : array
$data string XML string
리턴 array XML element object; otherwise, empty array

factory() 공개 메소드

Create an instance of the format class e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv();
public factory ( mixed $data, string $from_type = NULL ) : object
$data mixed Data to convert/parse
$from_type string Type to convert from e.g. json, csv, html
리턴 object Instance of the format class

to_array() 공개 메소드

Format data as an array
public to_array ( mixed | null $data = NULL ) : array
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
리턴 array Data parsed as an array; otherwise, an empty array

to_csv() 공개 메소드

public to_csv ( mixed | null $data = NULL, string $delimiter = ',', string $enclosure = '"' ) : string
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
$delimiter string The optional delimiter parameter sets the field delimiter (one character only). NULL will use the default value (,)
$enclosure string The optional enclosure parameter sets the field enclosure (one character only). NULL will use the default value (")
리턴 string A csv string

to_html() 공개 메소드

Format data as HTML
public to_html ( mixed | null $data = NULL ) : mixed
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
리턴 mixed

to_json() 공개 메소드

Encode data as json
public to_json ( mixed | null $data = NULL ) : string
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
리턴 string Json representation of a value

to_php() 공개 메소드

Format data using a PHP structure
public to_php ( mixed | null $data = NULL ) : mixed
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
리턴 mixed String representation of a variable

to_serialized() 공개 메소드

Encode data as a serialized array
public to_serialized ( mixed | null $data = NULL ) : string
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
리턴 string Serialized data

to_xml() 공개 메소드

Format data as XML
public to_xml ( mixed | null $data = NULL, null $structure = NULL, string $basenode = 'xml' ) : mixed
$data mixed | null Optional data to pass, so as to override the data passed to the constructor
$structure null
$basenode string
리턴 mixed

프로퍼티 상세

$_data 보호되어 있는 프로퍼티

Data to parse
protected mixed $_data
리턴 mixed

$_from_type 보호되어 있는 프로퍼티

Type to convert from
protected string $_from_type
리턴 string