Code Duplication    Length = 36-38 lines in 2 locations

src/Surfnet/StepupRa/RaBundle/Service/RaSecondFactorService.php 2 locations

@@ 97-134 (lines=38) @@
94
     * @param SearchRaSecondFactorsCommand $command
95
     * @return RaSecondFactorCollection
96
     */
97
    public function search(SearchRaSecondFactorsCommand $command)
98
    {
99
        $query = new RaSecondFactorSearchQuery($command->actorInstitution, $command->pageNumber);
100
101
        if ($command->name) {
102
            $query->setName($command->name);
103
        }
104
105
        if ($command->type) {
106
            $query->setType($command->type);
107
        }
108
109
        if ($command->secondFactorId) {
110
            $query->setSecondFactorId($command->secondFactorId);
111
        }
112
113
        if ($command->email) {
114
            $query->setEmail($command->email);
115
        }
116
117
        if ($command->status) {
118
            $query->setStatus($command->status);
119
        }
120
121
        if ($command->orderBy) {
122
            $query->setOrderBy($command->orderBy);
123
        }
124
        
125
        if ($command->institution) {
126
            $query->setInstitution($command->institution);
127
        }
128
129
        if ($command->orderDirection) {
130
            $query->setOrderDirection($command->orderDirection);
131
        }
132
133
        return $this->apiRaSecondFactorService->search($query);
134
    }
135
136
    /**
137
     * Searches for a collection of second factor tokens and returns a Http response with an attachment
@@ 143-178 (lines=36) @@
140
     * @param ExportRaSecondFactorsCommand $command
141
     * @return \Symfony\Component\HttpFoundation\Response
142
     */
143
    public function export(ExportRaSecondFactorsCommand $command)
144
    {
145
        $query = new RaSecondFactorExportQuery($command->institution);
146
147
        if ($command->name) {
148
            $query->setName($command->name);
149
        }
150
151
        if ($command->type) {
152
            $query->setType($command->type);
153
        }
154
155
        if ($command->secondFactorId) {
156
            $query->setSecondFactorId($command->secondFactorId);
157
        }
158
159
        if ($command->email) {
160
            $query->setEmail($command->email);
161
        }
162
163
        if ($command->status) {
164
            $query->setStatus($command->status);
165
        }
166
167
        if ($command->orderBy) {
168
            $query->setOrderBy($command->orderBy);
169
        }
170
171
        if ($command->orderDirection) {
172
            $query->setOrderDirection($command->orderDirection);
173
        }
174
175
        $collection = $this->apiRaSecondFactorService->searchForExport($query);
176
177
        return $this->exporter->export($collection, $query->getFileName());
178
    }
179
}
180