PHPackages                             baka/support - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. baka/support

ActiveLibrary

baka/support
============

The baka Support package.

1.3.0(6y ago)35.4k1MITPHPPHP &gt;=7.1

Since Mar 5Pushed 6y ago2 watchersCompare

[ Source](https://github.com/bakaphp/support)[ Packagist](https://packagist.org/packages/baka/support)[ Docs](https://mctekk.com)[ RSS](/packages/baka-support/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (1)Versions (7)Used By (1)

[![Build Status](https://camo.githubusercontent.com/9e548939f37eae938bcb523878c6e5bdfd37eba2bc672cb25f4b69b5aac8ba1b/68747470733a2f2f7472617669732d63692e636f6d2f62616b617068702f737570706f72742e7376673f6272616e63683d312e312e30)](https://travis-ci.com/bakaphp/support) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/033514b8ee0968d04684678f4c863eef830d014380435eaf80aa7dcb9d33484b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616b617068702f737570706f72742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bakaphp/support/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/1c360ddf15bbfd29023de28353039cb8f77de05da8426c4e13eaf1f5a2cbdcd2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616b617068702f737570706f72742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bakaphp/support/?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/f7896ec98227de373f01798826c1f26dac83ff266b415283ff02c463105a0133/68747470733a2f2f706f7365722e707567782e6f72672f62616b612f737570706f72742f762f737461626c65)](https://packagist.org/packages/baka/support) [![composer.lock](https://camo.githubusercontent.com/b9baf6388c30f92a33be742761fc45f1589c22a3ab4e8b2e03826e8292680425/68747470733a2f2f706f7365722e707567782e6f72672f62616b612f737570706f72742f636f6d706f7365726c6f636b)](https://packagist.org/packages/baka/support) [![Total Downloads](https://camo.githubusercontent.com/de2a0e3489702371e4dc322a6b965a51f46153808694d3a87a64bbbdc69532c2/68747470733a2f2f706f7365722e707567782e6f72672f62616b612f737570706f72742f646f776e6c6f616473)](https://packagist.org/packages/baka/support) [![License](https://camo.githubusercontent.com/77df3ee1a790d45ef7f5751a258ca90b0dfb968cd066cc1e041bc285e732d91e/68747470733a2f2f706f7365722e707567782e6f72672f62616b612f737570706f72742f6c6963656e7365)](https://packagist.org/packages/baka/support)

Baka Support
============

[](#baka-support)

A curated collection of useful PHP snippets.

Requirements
------------

[](#requirements)

This package requires PHP 7.2 or higher.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require baka/support
```

The package will automatically register itself.

---

📚 Array
-------

[](#-array)

### all

[](#all)

Returns `true` if the provided function returns `true` for all elements of an array, `false` otherwise.

```
all([2, 3, 4, 5], function ($item) {
    return $item > 1;
}); // true
```

### any

[](#any)

Returns `true` if the provided function returns `true` for at least one element of an array, `false` otherwise.

```
any([1, 2, 3, 4], function ($item) {
    return $item < 2;
}); // true
```

### deepFlatten

[](#deepflatten)

Deep flattens an array.

```
deepFlatten([1, [2], [[3], 4], 5]); // [1, 2, 3, 4, 5]
```

### drop

[](#drop)

Returns a new array with `n` elements removed from the left.

```
drop([1, 2, 3]); // [2,3]
drop([1, 2, 3], 2); // [3]
```

### findLast

[](#findlast)

Returns the last element for which the provided function returns a truthy value.

```
findLast([1, 2, 3, 4], function ($n) {
    return ($n % 2) === 1;
});
// 3
```

### findLastIndex

[](#findlastindex)

Returns the index of the last element for which the provided function returns a truthy value.

```
findLastIndex([1, 2, 3, 4], function ($n) {
    return ($n % 2) === 1;
});
// 2
```

### flatten

[](#flatten)

Flattens an array up to the one level depth.

```
flatten([1, [2], 3, 4]); // [1, 2, 3, 4]
```

### groupBy

[](#groupby)

Groups the elements of an array based on the given function.

```
groupBy(['one', 'two', 'three'], 'strlen'); // [3 => ['one', 'two'], 5 => ['three']]
```

### hasDuplicates

[](#hasduplicates)

Checks a flat list for duplicate values. Returns `true` if duplicate values exists and `false` if values are all unique.

```
hasDuplicates([1, 2, 3, 4, 5, 5]); // true
```

### head

[](#head)

Returns the head of a list.

```
head([1, 2, 3]); // 1
```

### last

[](#last)

Returns the last element in an array.

```
last([1, 2, 3]); // 3
```

### pluck

[](#pluck)

Retrieves all of the values for a given key:

```
pluck([
    ['product_id' => 'prod-100', 'name' => 'Desk'],
    ['product_id' => 'prod-200', 'name' => 'Chair'],
], 'name');
// ['Desk', 'Chair']
```

### pull

[](#pull)

Mutates the original array to filter out the values specified.

```
$items = ['a', 'b', 'c', 'a', 'b', 'c'];
pull($items, 'a', 'c'); // $items will be ['b', 'b']
```

### reject

[](#reject)

Filters the collection using the given callback.

```
reject(['Apple', 'Pear', 'Kiwi', 'Banana'], function ($item) {
    return strlen($item) > 4;
}); // ['Pear', 'Kiwi']
```

### remove

[](#remove)

Removes elements from an array for which the given function returns false.

```
remove([1, 2, 3, 4], function ($n) {
    return ($n % 2) === 0;
});
// [0 => 1, 2 => 3]
```

### tail

[](#tail)

Returns all elements in an array except for the first one.

```
tail([1, 2, 3]); // [2, 3]
```

### take

[](#take)

Returns an array with n elements removed from the beginning.

```
take([1, 2, 3], 5); // [1, 2, 3]
take([1, 2, 3, 4, 5], 2); // [1, 2]
```

### without

[](#without)

Filters out the elements of an array, that have one of the specified values.

```
without([2, 1, 2, 3], 1, 2); // [3]
```

### orderBy

[](#orderby)

Sorts a collection of arrays or objects by key.

```
orderBy(
    [
        ['id' => 2, 'name' => 'Joy'],
        ['id' => 3, 'name' => 'Khaja'],
        ['id' => 1, 'name' => 'Raja']
    ],
    'id',
    'desc'
); // [['id' => 3, 'name' => 'Khaja'], ['id' => 2, 'name' => 'Joy'], ['id' => 1, 'name' => 'Raja']]
```

---

📜 String
--------

[](#-string)

### endsWith

[](#endswith)

Check if a string is ends with a given substring.

```
endsWith('Hi, this is me', 'me'); // true
```

### firstStringBetween

[](#firststringbetween)

Returns the first string there is between the strings from the parameter start and end.

```

```php
firstStringBetween('This is a [custom] string', '[', ']'); // custom

```

### isAnagram

[](#isanagram)

Compare two strings and returns `true` if both strings are anagram, `false` otherwise.

```
isAnagram('act', 'cat'); // true
```

### isLowerCase

[](#islowercase)

Returns `true` if the given string is lower case, `false` otherwise.

```
isLowerCase('Morning shows the day!'); // false
isLowerCase('hello'); // true
```

### isUpperCase

[](#isuppercase)

Returns `true` if the given string is upper case, false otherwise.

```
isUpperCase('MORNING SHOWS THE DAY!'); // true
isUpperCase('qUick Fox'); // false
```

### palindrome

[](#palindrome)

Returns `true` if the given string is a palindrome, `false` otherwise.

```
palindrome('racecar'); // true
palindrome(2221222); // true
```

### startsWith

[](#startswith)

Check if a string starts with a given substring.

```
startsWith('Hi, this is me', 'Hi'); // true
```

### countVowels

[](#countvowels)

Returns number of vowels in provided string.

Use a regular expression to count the number of vowels (A, E, I, O, U) in a string.

```
countVowels('sampleInput'); // 4
```

### decapitalize

[](#decapitalize)

Decapitalizes the first letter of a string.

Decapitalizes the first letter of the string and then adds it with rest of the string. Omit the `upperRest` parameter to keep the rest of the string intact, or set it to `true` to convert to uppercase.

```
decapitalize('FooBar'); // 'fooBar'
```

### contains

[](#contains)

Check if a word / substring exist in a given string input. Using `strpos` to find the position of the first occurrence of a substring in a string. Returns either `true` or `false`

```
contains('This is an example string', 'example'); // true
```

```
contains('This is an example string', 'hello'); // false
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [License File](LICENSE) for details

---

### Thanks

[](#thanks)

Thanks to [appzcoder](https://github.com/appzcoder) for the snippets!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~101 days

Total

5

Last Release

2222d ago

PHP version history (2 changes)1.0.0PHP ^7.0

1.1.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/136c850ea7ec76b23cc5b1fed8507683cc891145cffedc7761fe73ce03960df3?d=identicon)[mctekk](/maintainers/mctekk)

---

Top Contributors

[![gabbanaesteban](https://avatars.githubusercontent.com/u/11374198?v=4)](https://github.com/gabbanaesteban "gabbanaesteban (20 commits)")[![kaioken](https://avatars.githubusercontent.com/u/118385?v=4)](https://github.com/kaioken "kaioken (9 commits)")[![SidRoberts](https://avatars.githubusercontent.com/u/1364214?v=4)](https://github.com/SidRoberts "SidRoberts (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/baka-support/health.svg)

```
[![Health](https://phpackages.com/badges/baka-support/health.svg)](https://phpackages.com/packages/baka-support)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
