PHP Class Nwidart\Modules\Json

Show file Open project: nwidart/laravel-modules Class Usage Examples

Protected Properties

Property Type Description
$attributes Illuminate\Support\Collection The attributes collection.
$filesystem Illuminate\Filesystem\Filesystem The laravel filesystem instance.
$path string The file path.

Public Methods

Method Description
__call ( string $method, array $arguments = [] ) : mixed Handle call to __call method.
__construct ( mixed $path, Illuminate\Filesystem\Filesystem $filesystem = null ) The constructor.
__get ( string $key ) : mixed Handle magic method __get.
__toString ( ) : string Handle call to __toString method.
get ( $key, null $default = null ) : mixed Get the specified attribute from json file.
getAttributes ( ) : array Get file contents as array.
getContents ( ) : string Get file content.
getFilesystem ( ) : Illuminate\Filesystem\Filesystem Get filesystem.
getPath ( ) : string Get path.
make ( string $path, Illuminate\Filesystem\Filesystem $filesystem = null ) : static Make new instance.
save ( ) : boolean Save the current attributes array to the file storage.
set ( string $key, mixed $value ) Set a specific key & value.
setFilesystem ( Illuminate\Filesystem\Filesystem $filesystem ) Set filesystem.
setPath ( mixed $path ) Set path.
toJsonPretty ( array $data = null ) : string Convert the given array data to pretty json.
update ( array $data ) : boolean Update json contents from array data.

Method Details

__call() public method

Handle call to __call method.
public __call ( string $method, array $arguments = [] ) : mixed
$method string
$arguments array
return mixed

__construct() public method

The constructor.
public __construct ( mixed $path, Illuminate\Filesystem\Filesystem $filesystem = null )
$path mixed
$filesystem Illuminate\Filesystem\Filesystem

__get() public method

Handle magic method __get.
public __get ( string $key ) : mixed
$key string
return mixed

__toString() public method

Handle call to __toString method.
public __toString ( ) : string
return string

get() public method

Get the specified attribute from json file.
public get ( $key, null $default = null ) : mixed
$key
$default null
return mixed

getAttributes() public method

Get file contents as array.
public getAttributes ( ) : array
return array

getContents() public method

Get file content.
public getContents ( ) : string
return string

getFilesystem() public method

Get filesystem.
public getFilesystem ( ) : Illuminate\Filesystem\Filesystem
return Illuminate\Filesystem\Filesystem

getPath() public method

Get path.
public getPath ( ) : string
return string

make() public static method

Make new instance.
public static make ( string $path, Illuminate\Filesystem\Filesystem $filesystem = null ) : static
$path string
$filesystem Illuminate\Filesystem\Filesystem
return static

save() public method

Save the current attributes array to the file storage.
public save ( ) : boolean
return boolean

set() public method

Set a specific key & value.
public set ( string $key, mixed $value )
$key string
$value mixed

setFilesystem() public method

Set filesystem.
public setFilesystem ( Illuminate\Filesystem\Filesystem $filesystem )
$filesystem Illuminate\Filesystem\Filesystem

setPath() public method

Set path.
public setPath ( mixed $path )
$path mixed

toJsonPretty() public method

Convert the given array data to pretty json.
public toJsonPretty ( array $data = null ) : string
$data array
return string

update() public method

Update json contents from array data.
public update ( array $data ) : boolean
$data array
return boolean

Property Details

$attributes protected property

The attributes collection.
protected Collection,Illuminate\Support $attributes
return Illuminate\Support\Collection

$filesystem protected property

The laravel filesystem instance.
protected Filesystem,Illuminate\Filesystem $filesystem
return Illuminate\Filesystem\Filesystem

$path protected property

The file path.
protected string $path
return string