function it_return_default_if_value_not_exists(Repository $repository) { $repository->get('resources.resource_a')->willReturn(null); $this->getResource('resources.resource_a', 'my_default')->shouldReturn('my_default'); }
/** * @param $key * @return mixed|null */ public function getResource($key) { return $this->repository->get($key); }
function it_return_value_for_key_from_repository(Repository $repository) { $repository->get('resources.resource_a')->willReturn('resource_value'); $this->getResource('resources.resource_a')->shouldReturn('resource_value'); }
/** * @param $key * @return mixed|null */ public function getResource($key, $default = null) { $value = $this->repository->get($key); return is_null($value) ? $default : $value; }