2017 © Pedro Peláez
 

library repository

Fluent storage repository with dot notated key support

image

bhittani/repository

Fluent storage repository with dot notated key support

  • Thursday, March 15, 2018
  • by bhittani
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Repository

Travis Build Status Codacy Coverage Codacy Grade Packagist Downloads License, (*1)

Fluent storage repository with dot notated key support., (*2)

Install

You may install this package using composer., (*3)

$ composer require bhittani/repository

Usage

This package provides a fluent and intuitive storage repository., (*4)

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Bhittani\Repository\Repository;

$storage = new Repository;

// See below examples for usage...

Store and retrieve values

// Store and retrieve a value.
$storage->set('foo', 'bar');
echo $storage->get('foo'); // 'bar'

// Store an array and retrieve a value using dot notated key access.
$storage->set('app', ['name' => 'Acme', 'version' => '0.1.0']);
echo $storage->get('app.version'); // '0.1.0'

// Store a value using dot notated keys.
$storage->set('db.sqlite.path', ':memory:');
$storage->set('db.sqlite.prefix', 'acme_');
var_dump($storage->get('db.sqlite')); // ['path' => ':memory:', 'prefix' => 'acme_']

Preset an undefined key

$storage->preset('a', 'b');
echo $storage->get('a'); // 'b'

$storage->set('x', 'y');
$storage->preset('x', 'z');
echo $storage->get('x'); // 'y'

Append a value

$storage->set('append', ['foo']);
$storage->append('append', 'bar');
var_dump($storage->get('append')); // ['foo', 'bar']

Prepend a value

$storage->set('prepend', ['foo']);
$storage->append('prepend', 'bar');
var_dump($storage->get('prepend')); // ['bar', 'foo]

Increment a value

echo $storage->get('incr'); // null

$storage->increment('incr');
echo $storage->get('incr'); // 1

$storage->increment('incr', 5);
echo $storage->get('incr'); // 6

Decrement a value

echo $storage->get('decr'); // null

$storage->decerement('decr');
echo $storage->get('decr'); // -1

$storage->decerement('decr', 5);
echo $storage->get('decr'); // -6

Fallback to a default value

echo $storage->get('bar'); // null

echo $storage->get('bar', 'fallback'); // 'fallback'

Check whether a key is set

var_dump($storage->has('bar')); // (bool) false

Get all items

$storage->add('foo', 'bar');
$storage->add('beep.boop', 'baz');

var_dump($storage->all()); // ['foo' => 'bar', 'beep' => ['boop' => 'baz']]

Changelog

Please see CHANGELOG for more information on what has changed., (*5)

Testing

$ git clone https://github.com/kamalkhan/repository
$ cd repository
$ composer install
$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*6)

Security

If you discover any security related issues, please email shout@bhittani.com instead of using the issue tracker., (*7)

Credits

License

The MIT License (MIT). Please see the License File for more information., (*8)

, (*9)

The Versions

15/03 2018

dev-master

9999999-dev https://github.com/kamalkhan/repository

Fluent storage repository with dot notated key support

  Sources   Download

MIT

The Requires

  • php >=5.5,<8.0-DEV

 

The Development Requires

repository configuration storage dot-notation fluent

15/03 2018

0.1.0

0.1.0.0 https://github.com/kamalkhan/repository

Fluent storage repository with dot notated key support

  Sources   Download

MIT

The Requires

  • php >=5.5,<8.0-DEV

 

The Development Requires

repository configuration storage dot-notation fluent