Menu

## Arrayable
in package
Uses Microable

Arrayable.php : 11

### Table of Contents

#### Properties

$macros : array<string|int, mixed>
$array : array<string|int, mixed>
  The array to be manipulated

#### Methods

__call() : mixed
  Dynamically handle calls to the class.
__callStatic() : mixed
  Dynamically handle calls to the class.
__construct() : mixed
__get() : mixed
__isset() : mixed
__set() : mixed
__toString() : string
__unset() : mixed
add() : Arrayable
  Add a key value pair to the array If only the key is provided, the key will be the value
addAfter() : static
addAtKey() : $this
  Adds the $value to the current value of $key.
addBefore() : static
all() : array<string|int, mixed>
arrayType() : string
  Get the type of the array
at() : mixed
  Get the value at a certain index
chunk() : Arrayable
  Chunk the array
differenceFrom() : Arrayable
  Returns the items in the current array that are not in the other array
each() : Arrayable
  Each through the array
filter() : Arrayable
  Filter the array
first() : false|mixed
  Get the first item in the array
flush() : $this
  Reset the array
flushMacros() : void
  Remove all the macros we had registered
get() : mixed
  Get an item from the array
getA() : mixed
getArray() : array<string|int, mixed>|null
getArrayable() : Arrayable|null
getBool() : bool|null
getFloat() : float|null
getInt() : int|null
getJson() : false|string|null
getNegativeInteger() : int|null
getOrThrow() : mixed
getPositiveInteger() : int|null
getString() : string|null
has() : bool
  Check if the array has a key
hasMacro() : bool
  Check if we have a method in the balonables
isAssoc() : bool
  Checks if an array is associative
isEmpty() : bool
  Checks if the array is empty
isFilled() : bool
isMixed() : bool
  Checks if an array has both numeric and string keys
keys() : array<string|int, mixed>
  Get the keys of the array
keysToLowerCase() : $this
  Convert the keys of the array to lowercase
keysToUpperCase() : $this
  Convert the keys of the array to uppercase
last() : false|mixed
  Get the last item in the array
macro() : void
  Add a new mixable to the macros
map() : Arrayable
  Map through the array
mapWithKeys() : Arrayable
  Map through the array and flatten the result to a single array of values by using the callback
merge() : Arrayable
  Merge a whole into the current array
mixin() : void
  Mix another object into the class.
only() : Arrayable
  Get a subset of the items from the given array.
pop() : mixed
reduce() : Arrayable
  Reduce the array
remove() : Arrayable
  Remove an item from the array
replace() : static
reverse() : Arrayable
  Reverse the array
set() : $this
  Set an item in the array by key and value
shift() : mixed
size() : int
  Get the size of the array
slice() : $this
  Slice the array
sort() : Arrayable
  Sort the array
sortKeys() : Arrayable
  Sort the keys of the array
sortValues() : Arrayable
  Sort the values of the array
toArray() : array<string|int, mixed>
  Convert the arrayable object to an array
toArrayable() : Arrayable
toJson() : string
  Convert the arrayable to json
type() : string
  Return the type of the underlying array object
unshift() : static
values() : array<string|int, mixed>
  Get the values of the array
valuesToLowerCase() : Arrayable
  Convert the values of the array to lowercase
where() : Arrayable
  Filter the array using the given callback.

### Properties

#### $macros

Microable.php : 14
`protected static array<string|int, mixed> $macros = []`

#### $array

Arrayable.php : 19

The array to be manipulated

`private array<string|int, mixed> $array = []`

### Methods

#### __call()

Microable.php : 101

Dynamically handle calls to the class.

`public __call(string $method, array<string|int, mixed> $parameters) : mixed`

##### Parameters

$method : string
$parameters : array<string|int, mixed>

##### Tags

throws
  BadMethodCallException

#### __callStatic()

Microable.php : 75

Dynamically handle calls to the class.

`public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed`

##### Parameters

$method : string
$parameters : array<string|int, mixed>

##### Tags

throws
  BadMethodCallException

#### __construct()

Arrayable.php : 21
`public __construct([array<string|int, mixed> $array = [] ]) : mixed`

##### Parameters

$array : array<string|int, mixed> = []

#### __get()

Arrayable.php : 445
`public __get(mixed $name) : mixed`

##### Parameters

$name : mixed

#### __isset()

Arrayable.php : 455
`public __isset(mixed $name) : mixed`

##### Parameters

$name : mixed

#### __set()

Arrayable.php : 450
`public __set(mixed $name, mixed $value) : mixed`

##### Parameters

$name : mixed
$value : mixed

#### __toString()

Arrayable.php : 298
`public __toString() : string`

##### Return values

string

#### __unset()

Arrayable.php : 460
`public __unset(mixed $name) : mixed`

##### Parameters

$name : mixed

#### add()

Arrayable.php : 409

Add a key value pair to the array If only the key is provided, the key will be the value

`public add(string $key[, mixed|null $value = null ]) : Arrayable`

##### Parameters

$key : string
$value : mixed|null = null

##### Return values

Arrayable

#### addAfter()

Arrayable.php : 484
`public addAfter(mixed $positionKey, mixed $key[, mixed $value = null ]) : static`

##### Parameters

$positionKey : mixed
$key : mixed
$value : mixed = null

##### Return values

static

#### addAtKey()

Arrayable.php : 345

Adds the $value to the current value of $key.

`public addAtKey(string $key, mixed $value) : $this`

If the value is numeric, it will be added to the current value If the value is a string, it will be concatenated to the current value If the value is an array, it will be merged with the current value

##### Parameters

$key : string
$value : mixed

##### Return values

$this

#### addBefore()

Arrayable.php : 497
`public addBefore(string $positionKey, string $key[, mixed $value = null ]) : static`

##### Parameters

$positionKey : string
$key : string
$value : mixed = null

##### Return values

static

#### all()

Arrayable.php : 540
`public all() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### arrayType()

Arrayable.php : 85

Get the type of the array

`public arrayType([array<string|int, mixed>|null $arr = null ]) : string`

##### Parameters

$arr : array<string|int, mixed>|null = null

##### Return values

string

#### at()

Arrayable.php : 560

Get the value at a certain index

`public at(int $index) : mixed`

##### Parameters

$index : int

#### chunk()

Arrayable.php : 224

Chunk the array

`public chunk(int $size[, bool $preserve_keys = false ]) : Arrayable`

##### Parameters

$size : int
$preserve_keys : bool = false

##### Return values

Arrayable

#### differenceFrom()

Arrayable.php : 771

Returns the items in the current array that are not in the other array

`public differenceFrom(Arrayable|array<string|int, mixed> $arrayable) : Arrayable`

##### Parameters

$arrayable : Arrayable|array<string|int, mixed>

##### Return values

Arrayable

#### each()

Arrayable.php : 153

Each through the array

`public each(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Return values

Arrayable

#### filter()

Arrayable.php : 130

Filter the array

`public filter([callable|null $callback = null ]) : Arrayable`

##### Parameters

$callback : callable|null = null

##### Return values

Arrayable

#### first()

Arrayable.php : 274

Get the first item in the array

`public first() : false|mixed`

##### Return values

false|mixed

#### flush()

Arrayable.php : 549

Reset the array

`public flush() : $this`

##### Return values

$this

#### flushMacros()

Microable.php : 61

Remove all the macros we had registered

`public static flushMacros() : void`

#### get()

Arrayable.php : 311

Get an item from the array

`public get(string|null $name[, mixed|null $default = null ]) : mixed`

If checkUpperAndLower is set to true, the method will check for uppercase and lowercase cases

##### Parameters

$name : string|null
$default : mixed|null = null

#### getA()

Arrayable.php : 725
`public getA(string $key, string $className) : mixed`

##### Parameters

$key : string
$className : string

##### Tags

throws
  Exception

#### getArray()

Arrayable.php : 704
`public getArray(string $key) : array<string|int, mixed>|null`

##### Parameters

$key : string

##### Return values

array<string|int, mixed>|null

#### getArrayable()

Arrayable.php : 713
`public getArrayable(string $key) : Arrayable|null`

##### Parameters

$key : string

##### Return values

Arrayable|null

#### getBool()

Arrayable.php : 695
`public getBool(string $key) : bool|null`

##### Parameters

$key : string

##### Return values

bool|null

#### getFloat()

Arrayable.php : 670
`public getFloat(string $key) : float|null`

##### Parameters

$key : string

##### Return values

float|null

#### getInt()

Arrayable.php : 661
`public getInt(string $key) : int|null`

##### Parameters

$key : string

##### Return values

int|null

#### getJson()

Arrayable.php : 682
`public getJson(mixed $key) : false|string|null`

##### Parameters

$key : mixed

##### Tags

throws
  JsonException

##### Return values

false|string|null

#### getNegativeInteger()

Arrayable.php : 754
`public getNegativeInteger(string $key) : int|null`

##### Parameters

$key : string

##### Return values

int|null

#### getOrThrow()

Arrayable.php : 364
`public getOrThrow(string $key[, Throwable|string|null $exception = null ]) : mixed`

##### Parameters

$key : string
$exception : Throwable|string|null = null

##### Tags

throws
  Throwable

#### getPositiveInteger()

Arrayable.php : 742
`public getPositiveInteger(string $key) : int|null`

##### Parameters

$key : string

##### Return values

int|null

#### getString()

Arrayable.php : 649
`public getString(string $key) : string|null`

##### Parameters

$key : string

##### Return values

string|null

#### has()

Arrayable.php : 435

Check if the array has a key

`public has(string $key) : bool`

##### Parameters

$key : string

##### Return values

bool

#### hasMacro()

Microable.php : 53

Check if we have a method in the balonables

`public static hasMacro(string $name) : bool`

##### Parameters

$name : string

##### Return values

bool

#### isAssoc()

Arrayable.php : 48

Checks if an array is associative

`public isAssoc([array<string|int, mixed>|null $arr = null ]) : bool`

##### Parameters

$arr : array<string|int, mixed>|null = null

##### Return values

bool

#### isEmpty()

Arrayable.php : 392

Checks if the array is empty

`public isEmpty() : bool`

##### Return values

bool

#### isFilled()

Arrayable.php : 397
`public isFilled() : bool`

##### Return values

bool

#### isMixed()

Arrayable.php : 59

Checks if an array has both numeric and string keys

`public isMixed([array<string|int, mixed>|null $arr = null ]) : bool`

##### Parameters

$arr : array<string|int, mixed>|null = null

##### Return values

bool

#### keys()

Arrayable.php : 100

Get the keys of the array

`public keys() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### keysToLowerCase()

Arrayable.php : 234

Convert the keys of the array to lowercase

`public keysToLowerCase() : $this`

##### Return values

$this

#### keysToUpperCase()

Arrayable.php : 244

Convert the keys of the array to uppercase

`public keysToUpperCase() : $this`

##### Return values

$this

#### last()

Arrayable.php : 284

Get the last item in the array

`public last() : false|mixed`

##### Return values

false|mixed

#### macro()

Microable.php : 22

Add a new mixable to the macros

`public static macro(string $key, $value) : void`

##### Parameters

$key : string
$value :

#### map()

Arrayable.php : 119

Map through the array

`public map(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Return values

Arrayable

#### mapWithKeys()

Arrayable.php : 603

Map through the array and flatten the result to a single array of values by using the callback

`public mapWithKeys(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Tags

example

      $this->arrayable->merge([
      [
      'first' => 'John',
      'last' => 'Doe',
      'age' => 22
      ],
      [
      'first' => 'Kate',
      'last' => 'Middleton',
      'age' => 30
      ],
      [
      'first' => 'Jane',
      'last' => 'Doe',
      'age' => 20
      ]
      ]);

      $map = $this->arrayable->mapWithKeys(function ($item) {
      return [$item['first'] => $item['age']];
      });
      dd($map->toArray());

      // Output
      [
      "John" => 22
      "Kate" => 30
      "Jane" => 20
      ]

##### Return values

Arrayable

#### merge()

Arrayable.php : 470

Merge a whole into the current array

`public merge(array<string|int, mixed>|Arrayable $array) : Arrayable`

##### Parameters

$array : array<string|int, mixed>|Arrayable

  $array

##### Return values

Arrayable

#### mixin()

Microable.php : 35

Mix another object into the class.

`public static mixin(object $mixin[, bool $replace = true ]) : void`

##### Parameters

$mixin : object
$replace : bool = true

##### Tags

throws
  ReflectionException

#### only()

Arrayable.php : 636

Get a subset of the items from the given array.

`public only([array<string|int, mixed>|string|null $keys = null ]) : Arrayable`

##### Parameters

$keys : array<string|int, mixed>|string|null = null

##### Return values

Arrayable

#### pop()

Arrayable.php : 521
`public pop() : mixed`

#### reduce()

Arrayable.php : 142

Reduce the array

`public reduce(callable $callback[, null $initial = null ]) : Arrayable`

##### Parameters

$callback : callable
$initial : null = null

##### Return values

Arrayable

#### remove()

Arrayable.php : 424

Remove an item from the array

`public remove(string $key) : Arrayable`

##### Parameters

$key : string

##### Return values

Arrayable

#### replace()

Arrayable.php : 510
`public replace(string $key[, mixed $value = null ]) : static`

##### Parameters

$key : string
$value : mixed = null

##### Return values

static

#### reverse()

Arrayable.php : 198

Reverse the array

`public reverse() : Arrayable`

##### Return values

Arrayable

#### set()

Arrayable.php : 330

Set an item in the array by key and value

`public set(string $key, mixed $value) : $this`

##### Parameters

$key : string
$value : mixed

##### Return values

$this

#### shift()

Arrayable.php : 516
`public shift() : mixed`

#### size()

Arrayable.php : 383

Get the size of the array

`public size() : int`

##### Return values

int

#### slice()

Arrayable.php : 212

Slice the array

`public slice(int $offset[, int|null $length = null ][, $preserve_keys = false ]) : $this`

##### Parameters

$offset : int
$length : int|null = null
$preserve_keys : = false

##### Return values

$this

#### sort()

Arrayable.php : 166

Sort the array

`public sort(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Return values

Arrayable

#### sortKeys()

Arrayable.php : 177

Sort the keys of the array

`public sortKeys(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Return values

Arrayable

#### sortValues()

Arrayable.php : 188

Sort the values of the array

`public sortValues(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Return values

Arrayable

#### toArray()

Arrayable.php : 265

Convert the arrayable object to an array

`public toArray() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### toArrayable()

Arrayable.php : 479
`public static toArrayable(array<string|int, mixed> $array) : Arrayable`

##### Parameters

$array : array<string|int, mixed>

##### Return values

Arrayable

#### toJson()

Arrayable.php : 293

Convert the arrayable to json

`public toJson() : string`

##### Return values

string

#### type()

Arrayable.php : 35

Return the type of the underlying array object

`public type() : string`

##### Return values

string

#### unshift()

Arrayable.php : 526
`public unshift(array<string|int, mixed> $value) : static`

##### Parameters

$value : array<string|int, mixed>

##### Return values

static

#### values()

Arrayable.php : 109

Get the values of the array

`public values() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### valuesToLowerCase()

Arrayable.php : 255

Convert the values of the array to lowercase

`public valuesToLowerCase() : Arrayable`

##### Return values

Arrayable

#### where()

Arrayable.php : 624

Filter the array using the given callback.

`public where(callable $callback) : Arrayable`

##### Parameters

$callback : callable

##### Return values

Arrayable

## Search results