Skip to content
This repository was archived by the owner on Dec 7, 2020. It is now read-only.

teqfw/back-data-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3762c75 · Feb 6, 2019

History

12 Commits
Oct 12, 2017
Feb 6, 2019
Oct 11, 2017
Oct 11, 2017
Jan 2, 2019
Oct 11, 2017
Jan 8, 2019

Repository files navigation

Data objects in Tequila Framework (PHP)

Goals

Data objects are used in TeqFW as improved \srdClass objects.

Prevent warnings

Prevent warnings if some property is not set yet:

stdClass:

$data = new \stdClass();
$val = $data->prop;
// PHP Notice:  Undefined property: stdClass::$prop in ...

Data object:

$data = new \TeqFw\Lib\Data();
$val = $data->prop; // $val = null

Set/get property by path

stdClass:

$data = new \stdClass();
$data->path = new \stdClass();
$data->path->to = new \stdClass();
$data->path->to->node = 'value';
$val = $data->path->to->node;   // $val = 'value'

Data object:

$data = new \TeqFw\Lib\Data();
$data->set('path/to/node', 'value');
$val = $data->get('path/to/node'); // $val = 'value'

Wrap arrays or other objects

$param = [
    'key1' => 'value1',
    'key2' => 'value2'
];
$obj = new \TeqFw\Lib\Data($param);
$val1 = $obj->key1; // $val1 = 'value1'
$val2 = $obj->key2; // $val2 = 'value2'

About

Data Objects in Tequila Framework (PHP)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published