2017 © Pedro Peláez
 

library base

Ariadne Component Library

image

arc/base

Ariadne Component Library

  • Monday, April 11, 2016
  • by Auke
  • Repository
  • 3 Watchers
  • 1 Stars
  • 3,207 Installations
  • PHP
  • 9 Dependents
  • 0 Suggesters
  • 3 Forks
  • 4 Open issues
  • 8 Versions
  • 15 % Grown

The README.md

arc\base common datatypes for ARC

Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

arc\base is part of ARC - a component library. This package provides a number of basic datatypes and operations that are used in most other ARC packages., (*2)

ARC is a spinoff from the Ariadne Web Application Platform and Content Management System http://www.ariadne-cms.org/., (*3)

Installation

You can install the full set of ARC components using composer:, (*4)

composer require arc/arc

Or you can start a new project with arc/arc like this:, (*5)

composer create-project arc/arc {$path}

Or just use this package:, (*6)

composer require arc/base

arc/base contains

  • path: parse paths, including relative paths, get parents, etc.
  • tree: methods to parse filesystem-like trees and search and alter them
  • hash: methods to ease common tasks with nested hashes
  • template: simple php based templates, with compile option
  • context: nested scope or stackable DI container
  • lambda: partial function application

Example code

\arc\path

\arc\path::collapse( '../', '/current/directory/' );
// => '/current/'

\arc\path::collapse( 'some//../where', '/current/directory' );
// => '/current/directory/where/'

\arc\path::collapse( '../../../', '/current/directory/' );
// => '/'

\arc\path::diff( '/a/b/', '/a/c/' );
// => '../c/'

\arc\path::parent( '/parent/child/' );
// => '/parent/'

\arc\path::map( '/some path/with "quotes"/', function( $entry ) {
    return urlencode( $entry, ENT_QUOTES );
});
// => '/some+path/with+%22quotes%22/'

\arc\path::reduce( '/a/b/', function( $result, $entry ) {
    return $result . $entry . '\\';
}, '\\' );
// => '\\a\\b\\';

\arc\tree

$tree = \arc\tree::expand([
    '/' => 'Root',
    '/foo/bar/' => 'Bar'
]);
// => NamedNode tree with '/' => Root, '/foo/' => null, '/foo/bar/' => 'Bar'

$hash = \arc\tree::collapse( $tree );
// [ '/' => 'Root', '/foo/bar/' => 'Bar' ]

$nodeValueWithAnR = \arc\tree::search( $tree, function($node) {
    if ( strpos( $node->nodeValue, 'R' )!==false ) {
        return $node->nodeValue;
    }
});
// => 'Root'

$Btree = \arc\tree::filter( $tree, function($node) {
    return ( strpos( $node->nodeValue, 'B' ) !== false );
});
// => [ '/foo/bar/' => 'Bar' ]

\arc\hash

\arc\hash::get( '/foo/bar/', [ 'foo' => [ 'bar' => 'baz' ] ] );
// => 'baz'

\arc\hash::get( '/foo/bar/', [ 'foo' => [  ] ], 'zilch' );
// => 'zilch'

\arc\hash::parseName( 'input[one]' );
// => '/input/one/'

\arc\hash::compileName( '/input/one' );
// => 'input[one]'

\arc\tree::collapse(
    \arc\hash::tree(
        [ 'foo' => [ 'bar' => 'A bar', 'baz' => 'Not a bar' ] ]
    )
);
// => [ '/foo/bar/' => 'A bar', '/foo/baz/' => 'Not a bar' ]

The Versions

11/04 2016

dev-master

9999999-dev https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Auke van Slooten

component components

28/01 2016

2.1.1

2.1.1.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Auke van Slooten

component components

28/01 2016

2.1

2.1.0.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Auke van Slooten

component components

18/12 2015

2.0

2.0.0.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Auke van Slooten

component components

02/07 2014

1.1

1.1.0.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Auke van Slooten

component components

23/06 2014

1.0.2

1.0.2.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

GPL

The Requires

  • php >=5.4

 

by Auke van Slooten

component components

21/06 2014

1.0.1

1.0.1.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

GPL

The Requires

  • php >=5.4

 

by Auke van Slooten

component components

20/06 2014

1.0

1.0.0.0 https://github.com/Ariadne-CMS/arc/wiki

Ariadne Component Library

  Sources   Download

GPL

The Requires

  • php >=5.4

 

by Auke van Slooten

component components