/** * Intercepts all reading property accesses and return corresponding Mockster instance * * @param string $name * @return Mockster * @throws \ReflectionException */ public function __get($name) { if (!array_key_exists($name, $this->propertyMocksters)) { if (!$this->properties->has($name)) { throw new \ReflectionException("The property [{$this->class}::{$name}] does not exist"); } if ($this->uuts) { $mockster = $this->properties[$name]->get($this->uuts[0])->__mockster; } else { $mockster = new Mockster($this->getTypeHint($name), $this->factory); } $this->propertyMocksters[$name] = $mockster; } return $this->propertyMocksters[$name]; }
/** * Determine if an property exists by key. * * @param string $key * * @return bool */ public function has($key) { if ($key === $this->entity->getKeyName()) { return false; } return $this->properties->has($key); }