public function check(Entity $entity) { $link = $entity->absoluteLink(); $fetch = app(Fetch::class); $data = $fetch->pull($link); if (!$fetch->isOk()) { return null; } $data = $this->fixHTML($data); $class = ucfirst(class_basename($entity)); $parser = new Parser(); if (method_exists($parser, $method = "parse{$class}")) { $data = $parser->{$method}($data); if (method_exists($this, $method = 'check' . $class)) { return $this->{$method}($entity, $data); } else { return $data; } } throw new CheckError($entity, 'Doesn\'t know, how to parse supplied html'); }