denis-kisel/helper

1.2 2020-06-19 13:27 UTC

This package is auto-updated.

Last update: 2025-02-20 00:11:38 UTC


README

Helper package for laravel

Installation

Via Composer

$ composer require denis-kisel/helper

Usage

String

Namespace DenisKisel\Helper\AStr

Example

String

use DenisKisel\Helper\AStr;

...

// Get substring by mask
AStr::getContent('{*}', 'some {placeholder} text');
// Return:
// placeholder

AStr::getContent('Hello * world', 'Hello wonderful world');
// Return:
// wonderful


// Remove substring by mask
$text = 'some {placeholder} text';
AStr::rm('{*}', $text);
// Return:
// {placeholder}

echo $text;
// Output:
// some text


// Check substring by mask
AStr::is('Hello * world', 'Hello wonderful world');
// Return:
// (boolean)true


// Format text
AStr::formatText('Some text', 3);
// Return:
// \t\t\tSome text\n


// Get path by class
AStr::pathByClass('App\\Models\\Page');
// Return: absolute path to input class


// Append substring
$text = <<<EOF
    function() {
        //TODO
    }
EOF;

AStr::append('function() {', 'echo __LINE__;', $text, $countTabs = 2);
// Return
//    function() {
//        echo __LINE__;
//        //TODO
//    }


// Prepend substring
$text = <<<EOF
    function() {
        //TODO
    }
EOF;

AStr::prepend('}', 'echo __LINE__;', $text, $countTabs = 2);
// Return
//    function() {
//        //TODO
//        echo __LINE__;
//    }
...