/** * Magic accessor * * @param string $name Key name * * @throws \InvalidArgumentException if referenced value is not an advisor * @return Advice */ public function __get($name) { if ($this->container->has($name)) { $advisor = $this->container->get($name); } else { list(, $advisorName) = explode('.', $name); list($aspect) = explode('->', $advisorName); $aspectInstance = $this->container->getAspect($aspect); $this->loader->loadAndRegister($aspectInstance); $advisor = $this->container->get($name); } if (!$advisor instanceof Advisor) { throw new \InvalidArgumentException("Reference {$name} is not an advisor"); } $this->{$name} = $advisor->getAdvice(); return $this->{$name}; }