2017 © Pedro Peláez
 

library helpers

A collection of php helper functions

image

hedii/helpers

A collection of php helper functions

  • Thursday, April 27, 2017
  • by hedii
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,194 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Helpers

A collection of php helper functions, (*2)

Table of contents

Installation

Install via composer, (*3)

composer require hedii/helpers

Usage

Available functions

Functions description

, (*4)

string_without(string $haystack, string $needle)

Remove a substring from a string. It returns the original string if the substring is not found., (*5)

$string = string_without('This is my name', ' is ');

// Thismy name

$string = string_without('This is my name', 'some string');

// This is my name

, (*6)

string_before(string $haystack, string $needle)

Get the string before a delimiter. It returns false if the string does not contains the delimiter., (*7)

$string = string_before('This is my name', ' name');

// This is my

$string = string_before('This is my name', 'some string');

// false

, (*8)

string_after(string $haystack, string $needle)

Get the string after a delimiter. It returns false if the string does not contains the delimiter., (*9)

$string = string_after('This is my name', 'This ');

// is my name

$string = string_after('This is my name', 'some string');

// false

, (*10)

string_between(string $haystack, string $needle1, string $needle2)

Get the string between two delimiters. It returns false if the string does not contains the two delimiters., (*11)

$string = string_between('This is my name', 'This ', ' name');

// is my

$string = string_between('This is my name', 'some', ' string');

// false

, (*12)

string_starts_with(string $haystack, string|array $needles)

Determines if the given string begins with the given value., (*13)

$value = string_starts_with('This is my name', 'This');

// true

, (*14)

string_ends_with(string $haystack, string|array $needles)

Determines if the given string ends with the given value., (*15)

$value = string_ends_with('This is my name', 'name');

// true

, (*16)

string_length(string $string)

Get the length of the given string., (*17)

$length = string_length('abcd');

// 4

, (*18)

string_is(string $pattern, string $string)

Determines if a given string matches a given pattern. Asterisks may be used to indicate wildcards., (*19)

$value = string_is('foo*', 'foobar');

// true

$value = string_is('baz*', 'foobar');

// false

, (*20)

string_contains(string $haystack, string|array $needles)

Determines if the given string contains the given value., (*21)

$value = string_contains('This is my name', 'my');

// true

$value = string_contains('This is my name', ['some string', 'my']);

// true

, (*22)

string_finish(string $string, string $cap)

Adds a single instance of the given value to a string., (*23)

$string = string_finish('this/string', '/');

// this/string/

$string = string_finish('this/string/', '/');

// this/string/

, (*24)

string_random(int $length = 32)

Generates a random string of the specified length., (*25)

$string = string_random(40);

// 6a2531aabec1fda11b0e0d9eaeb17d7ebfe1cdc5

, (*26)

is_url(string $string)

Determine if a string is a valid url., (*27)

is_url('http://example.com');

// true

is_url('tel:+1-111-222-333');

// false

, (*28)

class_basename(string|object $class)

Get the class "basename" of the given object / class., (*29)

$basename = class_basename(\Hedii\Helpers\HelpersTest);

// HelpersTest

, (*30)

is_windows_os()

Determine whether the current environment is Windows based., (*31)

is_window_os();

// false

Testing

composer test

License

helpers is released under the MIT Licence. See the bundled LICENSE file for details., (*32)

helpers contains some content from Laravel illuminate/support package. See the LARAVEL LICENSE file for details., (*33)

The Versions

27/04 2017

dev-master

9999999-dev

A collection of php helper functions

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

helpers php hedii

04/10 2016

1.1.1

1.1.1.0

A collection of php helper functions

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

helpers php hedii

15/09 2016

1.1.0

1.1.0.0

A collection of php helper functions

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

helpers php hedii

14/09 2016

1.0.0

1.0.0.0

A collection of php helper functions

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

helpers php hedii