Code Duplication    Length = 18-23 lines in 2 locations

lib/Cerbere/Model/Hacked/HackedProject.php 2 locations

@@ 180-202 (lines=23) @@
177
    /**
178
     * Hashes the remote project downloaded earlier.
179
     */
180
    public function hashRemoteProject()
181
    {
182
        // Only do this once, no matter how many times we're called.
183
        if (!empty($this->remote_hashed)) {
184
            return;
185
        }
186
187
        // Ensure that the remote project has actually been downloaded.
188
        $this->downloadRemoteProject();
189
190
        // Set up the remote file group.
191
        $base_path = $this->remote_files_downloader->getFinalDestination();
192
        $this->remote_files = HackedFileGroup::createFromDirectory($base_path);
193
        $this->remote_files->computeHashes();
194
195
        $this->remote_hashed = count($this->remote_files->getFiles()) > 0;
196
197
        // Logging.
198
        if (!$this->remote_hashed) {
199
            //throw new \Exception('Could not hash remote project: ' . $this->getTitle());
200
            echo 'Could not hash remote project: ' . $this->getTitle() . "\n";
201
        }
202
    }
203
204
    /**
205
     * Locate the base directory of the local project.
@@ 226-243 (lines=18) @@
223
    /**
224
     * Hash the local version of the project.
225
     */
226
    public function hashLocalProject()
227
    {
228
        // Only do this once, no matter how many times we're called.
229
        if (!empty($this->local_hashed)) {
230
            return;
231
        }
232
233
        $location = $this->locateLocalProject();
234
        $this->local_files = HackedFileGroup::createFromList($location, $this->remote_files->getFiles());
235
        $this->local_files->computeHashes();
236
        $this->local_hashed = count($this->local_files->getFiles()) > 0;
237
238
        // Logging.
239
        if (!$this->local_hashed) {
240
            //throw new \Exception('Could not hash remote project: ' . $this->getTitle());
241
            echo 'Could not hash local project: ' . $this->getTitle() . "\n";
242
        }
243
    }
244
245
    /**
246
     * Compute the differences between our version and the canonical version of the project.