2017 © Pedro Peláez
 

library freckle

A collection of dot-based information retrieval helpers... wuh?

image

enzyme/freckle

A collection of dot-based information retrieval helpers... wuh?

  • Sunday, April 3, 2016
  • by r3oath
  • Repository
  • 1 Watchers
  • 1 Stars
  • 118 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

, (*1)

Build Status Coverage Status Scrutinizer Code Quality, (*2)

Freckle is a collection of information accessors. It allows you to traverse and get the values in arrays and other collection types using dot separated paths. For example, getting the value in a multi-dimensional-associative array for users.bob456.name, given the array:, (*3)

$array = [
    'users' => [
        'jane123' => ['name' => 'Jane Foo'],
        'bob456'  => ['name' => 'Bob Foo'],
    ]
];

would return the value of Bob Foo. Pretty straight forward hey?, (*4)

Installation

composer require enzyme/freckle

Usage

Getting a value from a simple collection., (*5)

use Enzyme\Freckle\Dot;

$array = [
    'users' => [
        'jane123' => ['name' => 'Jane Foo'],
        'bob456'  => ['name' => 'Bob Foo'],
    ]
];

$dot = new Dot;
$full_name = $dot->get($array, 'users.bob456.name'); // returns "Bob Foo".

Getting a value from a simple collection with numeric keys., (*6)

use Enzyme\Freckle\Dot;

$array = [
    'users' => [
        0 => [
            'jane123' => ['name' => 'Jane Foo'],
        ],
        1 => [
            'bob456'  => ['name' => 'Bob Foo'],
        ]
    ]
];

$dot = new Dot;
$full_name = $dot->get($array, 'users.bob456.name'); // returns "Bob Foo".

In the event that a collection has numeric keys or supports multiple entries with the same key name, only the first result found will ever be returned., (*7)

If no value can be found, null will be returned instead. Be careful though if you're checking against the null value for success as you may get false positives if an actual value was found, but that value happens to be null., (*8)

Contributing

Please see CONTRIBUTING.md, (*9)

License

MIT - Copyright (c) 2015 Tristan Strathearn, see LICENSE, (*10)

The Versions

03/04 2016

dev-master

9999999-dev https://github.com/enzyme/freckle

A collection of dot-based information retrieval helpers... wuh?

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dot collections information path enzyme freckle retrieval

03/04 2016

dev-bleeding

dev-bleeding https://github.com/enzyme/freckle

A collection of dot-based information retrieval helpers... wuh?

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dot collections information path enzyme freckle retrieval

03/04 2016

v0.3.0

0.3.0.0 https://github.com/enzyme/freckle

A collection of dot-based information retrieval helpers... wuh?

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dot collections information path enzyme freckle retrieval

03/04 2016

v0.2.0

0.2.0.0 https://github.com/enzyme/freckle

A collection of dot-based information retrieval helpers... wuh?

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dot collections information path enzyme freckle retrieval

03/04 2016

v0.1.0

0.1.0.0 https://github.com/enzyme/freckle

A collection of dot-based information retrieval helpers... wuh?

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

dot collections information path enzyme freckle retrieval