2017 © Pedro Peláez
 

library dot-notation-access

Dot notation access arrays

image

gorka/dot-notation-access

Dot notation access arrays

  • Tuesday, May 26, 2015
  • by glopezdetorre
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4,356 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

⚠️ This project is unmaintained and might eventually be removed. Use it at your own risk., (*1)

Dot notation accessor & dot notation access array

Simple dot notation access for PHP arrays, (*2)

Build Status Code Coverage, (*3)

Example

<?php

use Gorka\DotNotationAccess\DotNotationAccessArray;

$mongoConnection = [
    'mongo' => [
        'default' => [
            'user' => 'username',
            'password' => 's3cr3t'
        ]
    ]
];
$config = new DotNotationAccessArray($mongoConnection);

// Get plain value

$user = $config->get('mongo.default.user');
/*
    $user = 'username';
*/ 

// Get array value

$mongoDefault = $config->get('mongo.default'); 
/* 
    $mongoDefault = ['user' => 'username', 'password' => 's3cr3t'];
*/

// Overwrite values

$overwrite = [
    'mongo' => [
        'default' => [
            'user' => 'myuser',
            'server' => 'localhost'
        ],
        'numbers' => [1, 1, 2, 3, 5, 8, 13]
    ],
    'title' => 'Dot Notation'
];

$config = $config->merge($overwrite);
$configDump = $config->getAll();
/*
    $configDump = [
        'mongo' => [
            'default' => [
                'user' => 'myuser',
                'password' => 's3cr3t',
                'server' => 'localhost',
            ],
            'numbers' => [1, 1, 2, 3, 5, 8, 13]
        ],
        'title' => 'Dot Notation'
    ];
*/

// Remove value

$config = $config->remove('mongo.default');
$configDump = $config->getAll();
/*
    $configDump = [
        'mongo' => [
            'numbers' => [1, 1, 2, 3, 5, 8, 13]
        ],
        'title' => 'Dot Notation'
    ];
*/


// Set values

$config = $config->set('mongo.numbers', [2, 3, 5, 7, 11]);
$configDump = $config->getAll();
/*
    $configDump = [
        'mongo' => [
            'numbers' => [2, 3, 5, 7, 11]
        ],
        'title' => 'Dot Notation'
    ];
*/

The Versions

26/05 2015

dev-master

9999999-dev

Dot notation access arrays

  Sources   Download

MIT

The Development Requires

26/05 2015

v1.0.0

1.0.0.0

Dot notation access arrays

  Sources   Download

MIT

The Development Requires