2017 © Pedro Peláez
 

library object-field-selector

Class for mapping large and complex object or varible into smaller object

image

jeurboy/object-field-selector

Class for mapping large and complex object or varible into smaller object

  • Tuesday, July 3, 2018
  • by jeurboy
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Field selector for PHP Object

Latest Stable Version Total Downloads Monthly Downloads Daily Downloads, (*1)

Description

The library for filter complex array/hash or object and return the actual fields you want to use., (*2)

If you have a large variables contained with unused values which not necessary to used. The library will helps by filter out all the unused fields and left your fields on return variable., (*3)

The library can traverse the complex array or nested array in any level of array/hash or object., (*4)


For a deeper knowledge of how to use this package, follow this index:, (*5)

Installation

You can install the package via composer require command:, (*6)

composer require jeurboy/object-field-selector

Or simply add it to your composer.json dependences and run composer update:, (*7)

"require": {
    "jeurboy/object-field-selector": "*"
}

Usage

For simple usage. Just create returned schema and send to DataParser;, (*8)

    $parser = new Jeurboy\SimpleObjectConverter\SchemaParser();
    $parser->addSchema("test1");
    $token = $parser->getParsedSchema();

    $data = [
        'test1' => "11234",
        'test2' => "22222"
    ];

    $DataParser = new Jeurboy\SimpleObjectConverter\DataParser();
    $return = $DataParser->getOutput($data, $token);
    print_r($return);

You will see following result., (*9)

Array
(
    [test1] => 11234
)

If you have nested Array just pass .(Dot) in your schema., (*10)

    $parser = new Jeurboy\SimpleObjectConverter\SchemaParser();
    $parser->addSchema("test1.eee");
    $token = $parser->getParsedSchema();

    $data = [
        'test1' => [
            'eee' => "hello holy",
        ]
    ];

    $DataParser = new Jeurboy\SimpleObjectConverter\DataParser();
    $return = $DataParser->getOutput($data, $token);
    print_r($return);

You will get result array like this., (*11)

Array
(
    [test1] => Array
        (
            [eee] => hello holy
        )
)

If there are multiple field inside input array, use comma(,) to define more fields., (*12)

    $parser = new Jeurboy\SimpleObjectConverter\SchemaParser();
    $parser->addSchema("test1");
    $token = $parser->getParsedSchema();

    $data = [
        'test1' => [
            'eee' => "hello holy",
            'fff' => "hello holy",
        ]
    ];

    $DataParser = new Jeurboy\SimpleObjectConverter\DataParser();
    $return = $DataParser->getOutput($data, $token);
    print_r($return);

You will see the result has multiple field returned., (*13)

Array
(
    [test1] => Array
        (
            [eee] => hello holy
            [fff] => hello holy
        )

)

The library also support object inside sequencial array., (*14)

    $parser = new Jeurboy\SimpleObjectConverter\SchemaParser();
    $parser->addSchema("test1.hello");
    $token = $parser->getParsedSchema();

    $data = [
        'test1' => [
            [
                "hello" => "world1",
                "ok"    => "google1",
            ],[
                "hello" => "world2",
                "ok"    => "google2",
            ],
        ]
    ];
    $DataParser = new Jeurboy\SimpleObjectConverter\DataParser();
    $return = $DataParser->getOutput($data, $token);
    print_r($return);

Result is, (*15)

Array
(
    [test1] => Array
        (
            [0] => Array
                (
                    [hello] => world1
                )

            [1] => Array
                (
                    [hello] => world2
                )

        )

)

You can see all test case in example/example.php files., (*16)

The Versions

03/07 2018

dev-master

9999999-dev

Class for mapping large and complex object or varible into smaller object

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Pornprasith Mahasith

03/07 2018

0.1.1

0.1.1.0

Class for mapping large and complex object or varible into smaller object

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Pornprasith Mahasith

02/07 2018

0.1.0

0.1.0.0

Class for mapping large and complex object or varible into smaller object

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Pornprasith Mahasith

29/06 2018

dev-develop

dev-develop

Class for mapping large and complex object or varible into smaller object

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Pornprasith Mahasith

29/06 2018

dev-feature/parser

dev-feature/parser

Class for mapping large and complex object or varible into smaller object

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Pornprasith Mahasith