![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/Classes/ |
<?php namespace Corals\Modules\Timesheet\Classes; use Illuminate\Support\Str; class BagParameters { /** * @var array */ protected array $parameters = []; /** * BagParameters constructor. * @param $parameters */ public function __construct($parameters) { $this->parameters = $parameters; } /** * @param $key * @return bool */ public function has($key) { return array_key_exists($key, $this->parameters); } /** * @param $key * @param null $default * @return array|mixed|null */ public function get($key, $default = null) { return data_get($this->parameters, $key, $default) ?? $default; } /** * @param $method * @return bool */ public function dynamicHas($method) { $key = lcfirst(substr($method, 3)); return $this->has($key); } /** * @param $method * @param null $default * @return array|mixed */ public function dynamicGet($method, $default = null) { $key = lcfirst(substr($method, 3)); return $this->get($key, $default); } /** * @param string $method * @param array $arguments * @return mixed */ public function __call(string $method, array $arguments) { if (Str::startsWith($method, 'has')) { return $this->dynamicHas($method); } if (Str::startsWith($method, 'get')) { return $this->dynamicGet($method, ...$arguments); } $this->throwBadMethodCallException($method); } /** * @param $method */ public function throwBadMethodCallException($method) { throw new \BadMethodCallException(sprintf( 'Call to undefined method %s::%s()', static::class, $method )); } }