Skip to content

A library to help on common stuff needed in every project.

Notifications You must be signed in to change notification settings

Braunstetter/helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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