Just a package for php helper classes.

v0.2.5 2022-07-29 16:53 UTC

This package is auto-updated.

Last update: 2024-10-29 06:31:08 UTC


README

Scrutinizer Code Quality Code Coverage Total Downloads License

A bundle for sharing usefully stuff around several projects.

Installation

composer require braunstetter/helper

Array

attachClass

This method is just handy when it comes to add a class to an existing class string.

Braunstetter\Helper\Arr::attachClass([ 'class' => 'mx-4 my-2' ], 'container')

# output:
# ['class' => 'mx-4 my-2 container']

attach

Sometimes just want to add some new attribute to an existing string.

Braunstetter\Helper\Arr::attach(
    [ 'data-controller' => 'example'],
    [ 'data-controller' => 'another-example']
)

# output: 
# ['data-controller' => 'example another-example']

firstValue

Returns the first value of a given array. If the array is empty it returns null.

Braunstetter\Helper\Arr::firstValue([
    3 => 'first',
    2 => 'second',
    0 => 'third'
])

# output:
# first