Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 1.56 KB

README.md

File metadata and controls

63 lines (44 loc) · 1.56 KB

Helper

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