2017 © Pedro Pelรกez
 

library helpers

Helpers that simplify the development process

image

andrey-helldar/helpers

Helpers that simplify the development process

  • Wednesday, July 11, 2018
  • by Helldar
  • Repository
  • 1 Watchers
  • 0 Stars
  • 150 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 38 Versions
  • 69 % Grown

The README.md

Helpers for Laravel 5.5+

Functions that simplify the development process., (*1)

helpers, (*2)

StyleCI Total Downloads Latest Stable Version Latest Unstable Version License , (*3)

Attention

This package is abandoned and no longer maintained. The author suggests using the andrey-helldar/support package instead., (*4)

Installation

To get the latest version of Helpers, simply require the project using Composer:, (*5)

$ composer require andrey-helldar/helpers

Instead, you may of course manually update your require block and run composer update if you so choose:, (*6)

{
    "require": {
        "andrey-helldar/helpers": "^1.0"
    }
}

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php:, (*7)

Helldar\Helpers\LaravelServiceProvider::class,

You can also publish the config file to change implementations (ie. interface to specific class):, (*8)

php artisan vendor:publish --provider="Helldar\Helpers\ServiceProvider"

Now you can use helpers or access directly to interfaces., (*9)

Enjoy!, (*10)

Documentation

Arrays

array_item_value_max_length()

Returns the number of characters of the longest element in the array:, (*11)

echo array_item_value_max_length(array $array = []) : int

echo (new \Helldar\Helpers\Support\Arr(array $array = []))
    ->arrayItemValueMaxLength() : int

array_add_unique()

Push one a unique element onto the end of array:, (*12)

array_add_unique(array &$array, $value)

(new \Helldar\Helpers\Support\Arr())
    ->addUnique(&$array, $value = 'value')

(new \Helldar\Helpers\Support\Arr())
    ->addUnique(&$array, $value = ['value1', 'value2', ...])

array_rename_keys()

Renaming array keys. As the first parameter, a callback function is passed, which determines the actions for processing the value. The output of the function must be a string with a name., (*13)

return array_rename_keys($callback, array $array = []) : array

return (new \Helldar\Helpers\Support\Arr(array $array = []))
    ->arrayRenameKeys($callback) : array

array_size_max_value()

Get the size of the longest text element of the array:, (*14)

return array_size_max_value(array $array = []) : int

return (new \Helldar\Helpers\Support\Arr((array $array = []))
    ->arraySizeOfMaxValue() : int

array_sort_by_keys_array()

Sort an associative array in the order specified by an array of keys., (*15)

array_sort_by_keys_array($array, $sorter) : void

(new \Helldar\Helpers\Support\Arr())
    ->sortByKeysArray($array, $sorter) : void
Example:
$arr = ['q' => 1, 'r' => 2, 's' => 5, 'w' => 123];

array_sort_by_keys_array($arr, ['q', 'w', 'e']);

print_r($arr);

/*
Array
(
    [q] => 1
    [w] => 123
    [r] => 2
    [s] => 5
)

[ to top | to menu ], (*16)

Digits

factorial()

Calculating the factorial of a number:, (*17)

echo factorial(int $n = 0) : int

echo (new \Helldar\Helpers\Support\Digits())
    ->factorial(int $n = 0) : int

short_number()

Converts a number into a short version:, (*18)

echo short_number($n = 0, $precision = 1) : int|string

echo (new \Helldar\Helpers\Support\Digits($n = 0))
    ->shortNumber($precision = 1) : int|string
Example:
short_number(576);
// returns: 576

short_number(1000);
// returns: 1K

short_number(1440);
// returns: 1.4K

short_number(3000000);
// returns: 3M

short_number(3000000000);
// returns: 3B

short_number(3000000000000);
// returns: 3T+

[ to top | to menu ], (*19)

Dumper

dd_sql()

Dump the passed variables and end the script., (*20)

return dd_sql($query, bool $is_short = false, bool $is_return = false) : array|string|void

return (new \Helldar\Helpers\Support\Dumper($query))
    ->ddSql($is_short, $is_return) : array|string|void

[ to top | to menu ], (*21)

Files

url_file_exists()

Checks whether a file or directory exists on URL:, (*22)

return url_file_exists($path) : bool

return (new \Helldar\Helpers\Support\Files($path))
    ->urlFileExists() : bool

[ to top | to menu ], (*23)

Http

mix_url()

Convert the relative path of a versioned Mix files to absolute., (*24)

return mix_url($path) : string

return (new \Helldar\Helpers\Support\Http($path))
    ->mixUrl() : string

base_url()

Get the domain name from the URL., (*25)

return base_url($url) : string

return (new \Helldar\Helpers\Support\Http($url))
    ->baseUrl() : string

build_url()

Reverse function for parse_url() (http://php.net/manual/en/function.parse-url.php)., (*26)

The code is taken from gist.github.com/Ellrion, (*27)

$parts1 = [
    'scheme' => 'http',
    'host'   => 'mysite.dev',
];

$parts2 = [
    'scheme'   => 'https',
    'host'     => 'mysite.dev',
    'port'     => 1234,
    'user'     => 'foo',
    'pass'     => 'bar',
    'path'     => '/category/subcategory',
    'query'    => 'page=1',
    'fragment' => 'section=5',
];

return build_url($parts1) : string
return (new \Helldar\Helpers\Support\Http($parts2))
    ->buildUrl();

// returned 1: http://mysite.dev
// returned 2: https://foo:bar@mysite.dev:1234/category/subcategory?page=1#section=5

subdomain_name()

Retrieving the current subdomain name., (*28)

return subdomain_name();

return (new \Helldar\Helpers\Support\Http())
    ->getSubdomain();

// from domain `test.mysite.local` will return `test` (string).
// from domain `mysite.local` will return `null` (null).

[ to top | to menu ], (*29)

Jsonable

Convert the object to its JSON representation., (*30)

The code is taken from gist.github.com/Ellrion, (*31)

use Helldar\Traits\Jsonable;

class MyClass
{
    use Jsonable;

    public function __construct($data)
    {
        $this->setData($data);
    }
}

$obj = new MyClass($data);
echo $obj->toJson();

[ to top | to menu ], (*32)

Images

image_or_default()

Check the existence of the file and return the default value if it is missing:, (*33)

echo image_or_default(string $filename, $default = null) : string

echo (new \Helldar\Helpers\Support\Images($filename))
    ->imageOrDefault($default = null) : string

[ to top | to menu ], (*34)

Notifications

Notification helpers were placed in a separate package andrey-helldar/notify-exceptions., (*35)

[ to top | to menu ], (*36)

Strings

str_choice()

The str_choice function translates the given language line with inflection:, (*37)

echo str_choice(int $num, array $choice = [], string $additional = '') : string

echo (new \Helldar\Helpers\Support\Str($num))
    ->choice(array $choice = [], string $additional = '') : string
Example:
echo str_choice(1, ['ะฟะพะปัŒะทะพะฒะฐั‚ะตะปัŒ', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปะตะน']);
// returned "ะฟะพะปัŒะทะพะฒะฐั‚ะตะปัŒ"

echo str_choice(3, ['ะฟะพะปัŒะทะพะฒะฐั‚ะตะปัŒ', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปะตะน']);
// returned "ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั"

echo str_choice(20, ['ะฟะพะปัŒะทะพะฒะฐั‚ะตะปัŒ', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปะตะน']);
// returned "ะฟะพะปัŒะทะพะฒะฐั‚ะตะปะตะน"

echo str_choice(20, ['ะฟะพะปัŒะทะพะฒะฐั‚ะตะปัŒ', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั', 'ะฟะพะปัŒะทะพะฒะฐั‚ะตะปะตะน'], 'ะทะดะตััŒ');
// returned "ะฟะพะปัŒะทะพะฒะฐั‚ะตะปะตะน ะทะดะตััŒ"

e()

Escape HTML special characters in a string:, (*38)

echo e($value) : string

echo (new \Helldar\Helpers\Support\Str($value))
    ->e() : string

de()

Convert special HTML entities back to characters:, (*39)

echo de($value) : string

echo (new \Helldar\Helpers\Support\Str($value))
    ->de() : string

str_replace_spaces()

Replacing multiple spaces with a single space., (*40)

echo str_replace_spaces($value) : string

echo (new \Helldar\Helpers\Support\Str($value))
    ->replaceSpaces() : string

[ to top | to menu ], (*41)

Systems

is_windows()

Determine whether the current environment is Windows based:, (*42)

return is_windows() : bool

return (new \Helldar\Helpers\Support\System())
    ->isWindows() : bool

is_linux()

Determine whether the current environment is Linux based:, (*43)

return is_linux() : bool

return (new \Helldar\Helpers\Support\System())
    ->isLinux() : bool

[ to top | to menu ], (*44)

Helpers was written by Andrey Helldar for the Laravel framework 5.5 or later, and is released under the MIT License. See the LICENSE file for details., (*45)

Translation

Translations of text and comment by Google Translate. Help with translation +1 in karma :), (*46)

The Versions

15/05 2018

1.3.11

1.3.11.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

09/05 2018

1.3.10

1.3.10.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

08/05 2018

1.3.9

1.3.9.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

07/05 2018

1.3.8

1.3.8.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

07/05 2018

1.3.1

1.3.1.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

05/05 2018

1.3.0

1.3.0.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/04 2018

1.2.0

1.2.0.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/04 2018

dev-analysis-8nDGBA

dev-analysis-8nDGBA http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/04 2018

dev-analysis-8AJLMP

dev-analysis-8AJLMP http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/04 2018

1.1.8

1.1.8.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/04 2018

1.1.7

1.1.7.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

13/04 2018

1.1.6

1.1.6.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

11/04 2018

1.1.5

1.1.5.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

07/02 2018

1.1.4

1.1.4.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

30/01 2018

1.1.3

1.1.3.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

30/01 2018

1.1.2

1.1.2.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/01 2018

1.1.1

1.1.1.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

18/01 2018

1.1.0

1.1.0.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

11/01 2018

1.0.13

1.0.13.0 http://ai-rus.com

Helpers that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

10/01 2018

1.0.12

1.0.12.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

27/12 2017

1.0.11

1.0.11.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

12/12 2017

1.0.10

1.0.10.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

11/12 2017

1.0.9

1.0.9.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

03/11 2017

1.0.8

1.0.8.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

03/11 2017

1.0.7

1.0.7.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel helpers helldar

24/10 2017

1.0.6

1.0.6.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar

23/10 2017

1.0.5

1.0.5.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar

20/09 2017

1.0.4

1.0.4.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar

20/09 2017

1.0.3

1.0.3.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar

19/09 2017

1.0.2

1.0.2.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar

18/09 2017

1.0.1

1.0.1.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar

18/09 2017

1.0.0

1.0.0.0 http://ai-rus.com

Functions that simplify the development process

  Sources   Download

MIT

The Requires

 

The Development Requires

helpers helldar