2017 © Pedro PelĂĄez
 

library lib-common

Shared classes of the Ride framework

image

ride/lib-common

Shared classes of the Ride framework

  • Thursday, September 8, 2016
  • by ride-user
  • Repository
  • 7 Watchers
  • 1 Stars
  • 12,288 Installations
  • PHP
  • 30 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 24 Versions
  • 4 % Grown

The README.md

Ride: Common Library

Shared classes of the PHP Ride framework., (*1)

What's In This Library

Decorators

Decorators are used to convert values from one context into another. They should only act when the incoming value is handable., (*2)

Check this code sample:, (*3)

<?php

use ride\library\decorator\DateFormatDecorator;
use ride\library\decorator\StorageSizeDecorator;
use ride\library\decorator\VariableDecorator;

// decorate dates into a formatted date
$decorator = new DateFormatDecorator();
$decorator->setDateFormat('y-m-d');
$result = $decorator->decorate(1372582573); // 2013-06-30
$result = $decorator->decorate(new DateTime('30 June 2013')); // 2013-06-30

// decorate byte values into human readable format
$decorator = new StorageSizeDecorator();
$result = $decorator->decorate(5000); // 4.88 Kb

// decorate variables into a output string
$decorator = new VariableDecorator();
$result = $decorator->decorate(null); // 'null'
$result = $decorator->decorate(true); // 'true'
$result = $decorator->decorate(array('key' => 'value')); // '["key" => "value"]'
$result = $decorator->decorate($decorator); // 'ride\library\decorator\VariableDecorator'

Autoloader

The autoloader of the Ride framework is a PSR-0 autoloader., (*4)

It handles class names like:, (*5)

  • ride\library\Autoloader: checked as ride/library/Autoloader.php
  • ride_library_Autoloader: checked as ride/library/Autoloader.php and ride_library_Autoloader.php

Check this code sample:, (*6)

<?php

use ride\library\Autoloader;
use ride\library\StringHelper;

require_once('path/to/ride/library/Autoloader.php');

$autoloader = new Autoloader();
$autoloader->addIncludePath('module1/src');
$autoloader->addIncludePath('module2/src');
$autoloader->addIncludePath('application/src'); // last added path will be checked first
$autoloader->registerAutoloader();

// go and use some classes
$string = StringHelper::generate();

Error Handler

The error handler of the Ride framework simply converts handable errors into exceptions., (*7)

Check this code sample:, (*8)

<?php

use ride\library\ErrorHandler;

$errorHandler = new ErrorHandler();
$errorHandler->registerErrorHandler();

try {
    $tokens = explode(null);
} catch (Exception $e) {
    // ErrorException thrown
}

String Helper

The string helper comes in handy when processing values., (*9)

<?php

use ride\library\StringHelper;

$string = "Let's create a stràngé STRING";
$result = StringHelper::safeString($string); // 'lets-create-a-strange-string'
$result = StringHelper::safeString($string, '_', false); // 'Lets_create_a_strange_STRING'
$result = StringHelper::startsWith($string, array('yes', 'no')); // false
$result = StringHelper::startsWith($string, array('yes', 'no', 'Let')); // true
$result = StringHelper::startsWith($string, 'let'); // false
$result = StringHelper::startsWith($string, 'let', true); // true
$result = StringHelper::truncate($string, 12); // 'Let's...'
$result = StringHelper::truncate($string, 12, '...', true); // 'Let's cre...'
$result = StringHelper::generate(10); // a random string of 10 characters

Timer

A timer can be used to track time of actions. It has a detail of microseconds., (*10)

<?php

use ride\library\Timer;

$timer = new Timer();
$timer->reset();
$time = $timer->getTime(); // get the current time and keep on going
$time = $timer->getTime(true); // get the current time and reset

Installation

You can use Composer to install this library., (*11)

composer require ride/lib-common

The Versions

08/09 2016

dev-master

9999999-dev

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

08/09 2016

dev-develop

dev-develop

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

08/09 2016

1.0.1

1.0.1.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

28/06 2016

1.0.0

1.0.0.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

19/01 2016

0.6.0

0.6.0.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

09/09 2015

0.5.0

0.5.0.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

12/08 2015

0.4.11

0.4.11.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

14/03 2015

0.4.10

0.4.10.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

02/03 2015

0.4.9

0.4.9.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

30/12 2014

0.4.8

0.4.8.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

20/12 2014

0.4.7

0.4.7.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

17/12 2014

0.4.6

0.4.6.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

07/11 2014

0.4.5

0.4.5.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

14/08 2014

0.4.4

0.4.4.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

14/08 2014

0.4.3

0.4.3.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

08/08 2014

0.4.2

0.4.2.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

04/05 2014

0.4.1

0.4.1.0

Shared classes of the Ride framework

  Sources   Download

MIT

by Joris Vandeweerd

10/01 2014

0.4.0

0.4.0.0

Shared classes of the Pallo framework

  Sources   Download

MIT

by Joris Vandeweerd

16/12 2013

0.3.2

0.3.2.0

Shared classes of the Pallo framework

  Sources   Download

MIT

by Joris Vandeweerd

28/09 2013

0.3.1

0.3.1.0

Shared classes of the Pallo framework

  Sources   Download

MIT

by Joris Vandeweerd

28/09 2013

0.3.0

0.3.0.0

Shared classes of the Pallo framework

  Sources   Download

MIT

by Joris Vandeweerd

27/09 2013

0.2.0

0.2.0.0

Shared classes of the Pallo framework

  Sources   Download

MIT

by Joris Vandeweerd

22/09 2013

0.1.1

0.1.1.0

Shared classes of the Pallo framework

  Sources   Download

MIT

by Joris Vandeweerd

30/06 2013

0.1.0

0.1.0.0

Shared classes of the Pallo framework

  Sources   Download

by Joris Vandeweerd