viloveul/support

用于打包所有第三方和常用帮助器的包装器

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

This package is auto-updated.

Last update: 2024-09-29 05:08:41 UTC


README

确保您的PHP版本 > 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);

帮助器

  • array_get($arrays, 'outer-key.sublevel-key.subsublevel-key.etc', '默认为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', '默认为null');

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