2017 © Pedro Peláez
 

library assistant

An assistant package consisted of helper classes

image

vinelab/assistant

An assistant package consisted of helper classes

  • Friday, October 30, 2015
  • by Vinelab
  • Repository
  • 1 Watchers
  • 3 Stars
  • 3,307 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 12 Versions
  • 8 % Grown

The README.md

Build Status, (*1)

Assistant

A bunch of helper classes that provides:, (*2)

  • Device detection (mobile, browser, bot, social network crawlers, etc.)
  • String formatting
  • Generating UUIDs (v4 compliant) and random IDs

Supports UTF-8 Character sets., (*3)

Installation

Dependencies

  • php 5.3+
  • mbstring (extension)

via Composer

composer require vinelab/assistant

Or add it to your composer.json, (*4)

{
     "require": {
         "vinelab/assistant": "*"
     }
 }

Laravel

Edit app.php and add 'Vinelab\Assistant\AssistantServiceProvider' to the 'providers' array., (*5)

It will automatically alias the classes Formatter, DeviceDetector and Generator, In case you would like to customize their names, edit the aliases array in app.php with the following:, (*6)

array(
    '...',
    'MyFormatter' => 'Vinelab\Assistant\Facades\Formatter',
    'MyGenerator' => 'Vinelab\Assistant\Facades\Generator',
    'MyDeviceDetector' => 'Vinelab\Assistant\Facades\DeviceDetector',
)

Formatter

    Formatter::snakify('my word to make a snake'); // output: my_word_to_make_a_snake

    Formatter::camelify('hakuna matata'); //output: hakunaMatata

    Formatter::neutralize('I hAtE whEn sOmEoNe wRites thInGs LIKE tHiS');
    // output: ihatewhensomeonewritesthingslikethis

    Formatter::dashit('bash cash slash'); // output: bash-cash-slash

    Formatter::date('10-02-2010 12:13:00'); // output: 10/02/10

    Formatter::date('10-02-2010 12:13:00', 'd-m-y'); // output: 10-02-10

    // Turn a camelCase string into dash-separated string
    Formatter::aliasify('simpleTest'); // output: simple-test

    Formatter::br2nl('a<br>b'); // output: a\nb

    // Clean up HTML formatting to be saved in the database or used as plain text
    // keeping links only as anchor tags. Solves an issue with editors when pasting
    // in text from word processors or web pages. PS: removes all sorts of media.
    Formatter::cleanHTML('<p>some</p><br><a href="#html">HTML</a><div>cleaned</div><img src="http://come.img" />');
    // output: some\n\n<a href="#html">HTML</a>\ncleaned\n

DeviceDetector

    $user_agent = $_SERVER['HTTP_USER_AGENT'];

    // or in case of laravel
    $user_agent = Request::server('HTTP_USER_AGENT');

    DeviceDetector::isMobile($user_agent); // true|false

    DeviceDetector::isBrowser($user_agent); // true|false

    DeviceDetector::isBot($user_agent); // true|false - also detects sharing bots

    DeviceDetector::isSharingBot($user_agent) // true|false

    DeviceDetector::whatIs($user_agent); // mobile|browser|bot|sharing-bot

    DeviceDetector::os($user_agent); // ios|android|blackberry|windows|other

Generator

    // Generate a UUID v4 compliant.
    $uuid = Generator::uuid();

    // unique identifier that does not exceed 30 chars
    $id = Generator::randomId(); // 907927051cdd15588d36

The Versions

30/10 2015

dev-master

9999999-dev

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

30/10 2015

v1.2.0

1.2.0.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

23/07 2015

v1.1.1

1.1.1.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

26/02 2015

v1.1.0

1.1.0.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2015

1.0.1

1.0.1.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

02/07 2014

1.0.0

1.0.0.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

16/12 2013

0.1.5

0.1.5.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

07/09 2013

0.1.4

0.1.4.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2013

0.1.3

0.1.3.0

An assistant package consisted of helper classes

  Sources   Download

MIT

The Requires

 

The Development Requires

20/06 2013

0.1.2

0.1.2.0

  Sources   Download

The Requires

 

The Development Requires

20/06 2013

0.1.1

0.1.1.0

  Sources   Download

The Requires

 

The Development Requires

20/06 2013

0.1

0.1.0.0

  Sources   Download

The Requires

 

The Development Requires