/** * @param $reference * @param null $default * * @return mixed|null * @throws \ObjectivePHP\Primitives\Exception */ public function get($reference, $default = null) { $reference = $this->computeKeyFQN($reference); // first look for exact match if (isset(self::$data[$reference])) { return self::$data[$reference]; } // otherwise use a matcher to return a // collection of matching entries $matcher = $this->getMatcher(); $matches = new Collection(); Collection::cast(self::$data)->each(function (&$value, $key) use($matcher, $reference, $matches) { if ($matcher->match($reference, $key)) { $matches[$key] = $value; } }); if (!$matches->isEmpty()) { return $matches; } return $default; }