viloveul/support

Wrapper for bundling all 3rd-party and common helpers

v1.0.7 2019-05-30 06:37 UTC

This package is auto-updated.

Last update: 2024-03-29 03:39:13 UTC


README

make sure your php version > 7.0

composer require viloveul/support

AttrAwareTrait

$object = new class implements ArrayAccess {

	use Viloveul\Support\AttrAwareTrait;

	private $attributes = [];	

};

$object->setAttributes(['anu' => 'gemes']);
$object->setFoo('bar');
$object->setAttributes('{"if": "print"}');

var_dump($object->getAnu(), $object->getDor('yes'), $object->getFoo('no'), $object->foo, $object['foo'], $object);

Helpers

  • array_get($arrays, 'outer-key.sublevel-key.subsublevel-key.etc', 'default is null');

  • array_has($arrays, 'outer-key.sublevel-key.subsublevel-key.etc');

  • array_only($arrays, ['index-one', 'index-four', 'index-five']);

  • item_to_array(any);

  • dd($someVariable, $otherVariable, $anotherVariable);

  • env('YOUR_KEY', 'default is null');

  • str_contains($str, $needle, $sensitive = true)