Code Duplication    Length = 27-28 lines in 2 locations

src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php 1 location

@@ 73-100 (lines=28) @@
70
     * @param IdentityQuery $query
71
     * @return \Doctrine\ORM\Query
72
     */
73
    public function createSearchQuery(
74
        IdentityQuery $query
75
    ) {
76
        $queryBuilder = $this->createQueryBuilder('i');
77
78
        // Modify query to filter on authorization
79
        $this->authorizationRepositoryFilter->filter($queryBuilder, $query->authorizationContext, 'i.id', 'i.institution', 'iac');
80
81
        if ($query->nameId) {
82
            $queryBuilder
83
                ->andWhere('i.nameId = :nameId')
84
                ->setParameter('nameId', $query->nameId);
85
        }
86
87
        if ($query->email) {
88
            $queryBuilder
89
                ->andWhere('MATCH_AGAINST(i.email, :email) > 0')
90
                ->setParameter('email', $query->email);
91
        }
92
93
        if ($query->commonName) {
94
            $queryBuilder
95
                ->andWhere('MATCH_AGAINST(i.commonName, :commonName) > 0')
96
                ->setParameter('commonName', $query->commonName);
97
        }
98
99
        return $queryBuilder->getQuery();
100
    }
101
102
    /**
103
     * @param string[] $nameIds

src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VerifiedSecondFactorRepository.php 1 location

@@ 94-120 (lines=27) @@
91
     * @param InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter
92
     * @return Query
93
     */
94
    public function createSearchQuery(VerifiedSecondFactorQuery $query)
95
    {
96
        $queryBuilder = $this->createQueryBuilder('sf');
97
98
        // Modify query to filter on authorization
99
        $this->authorizationRepositoryFilter->filter($queryBuilder, $query->authorizationContext, 'sf.id', 'sf.institution', 'iac');
100
101
        if ($query->identityId) {
102
            $queryBuilder
103
                ->andWhere('sf.identityId = :identityId')
104
                ->setParameter('identityId', (string) $query->identityId);
105
        }
106
107
        if ($query->secondFactorId) {
108
            $queryBuilder
109
                ->andWhere('sf.id = :secondFactorId')
110
                ->setParameter('secondFactorId', (string) $query->secondFactorId);
111
        }
112
113
        if (is_string($query->registrationCode)) {
114
            $queryBuilder
115
                ->andWhere('sf.registrationCode = :registrationCode')
116
                ->setParameter('registrationCode', $query->registrationCode);
117
        }
118
119
        return $queryBuilder->getQuery();
120
    }
121
122
    public function removeByIdentityId(IdentityId $identityId)
123
    {