client = $client; $this->ogpResolver = $ogpResolver; } public function resolve(string $url): Metadata { $res = $this->client->get($url); if ($res->getStatusCode() === 200) { $metadata = $this->ogpResolver->parse($res->getBody()); $metadata->image = preg_replace("~(pr|ps)\.jpg$~", 'pl.jpg', $metadata->image); $metadata->description = str_replace('<>', "", $metadata->description); return $metadata; } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } }