*/ class UserAgentsRepository extends Repository { protected function getEntityClassName() { return UserAgentEntity::class; } public function findOrCreate(string $userAgent): UserAgentEntity { $hash = (string)crc32($userAgent); $userAgentEntity = $this->findOneBy(['hash' => $hash]); if ($userAgentEntity) return $userAgentEntity; $userAgentEntity = new UserAgentEntity($userAgent); $this->persist($userAgentEntity); return $userAgentEntity; } }