pathMatches('/plaintext')) { return new HelloResource(false); } elseif ($request->pathMatches('/json')) { return new HelloResource(true); } elseif ($request->pathMatches('/db') || $request->pathMatches('/queries')) { return new DbResource($this->database()); } elseif ($request->pathMatches('/fortunes')) { return new FortuneResource($this->database()); } elseif ($request->pathMatches('/update')) { return new UpdateResource($this->database()); } } private function database(): Database { if (!$this->database) { $this->database = Database::mysql( 'p:tfb-database', 'benchmarkdbuser', 'benchmarkdbpass', 'hello_world' ); } return $this->database; } protected function getCache(Request $request): CacheItemPoolInterface { if (!$this->cache) { $this->cache = new ApcuCachePool(); } return $this->cache; } }