DownloadService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 6
Bugs 0 Features 0
Metric Value
c 6
b 0
f 0
dl 0
loc 21
rs 10
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A download() 0 18 2
1
<?php
2
3
namespace Juanber84\Services;
4
5
class DownloadService
6
{
7
    public function download($url)
8
    {
9
        // Todo: refactor and include in configuration
10
        $pathExec = "/usr/local/bin";
11
        try {
12
            $content = file_get_contents($url);
13
            file_put_contents($pathExec."/newdep", $content);
14
            unlink($pathExec.'/dep');
15
            $content = file_get_contents($pathExec."/newdep");
16
            file_put_contents($pathExec."/dep", $content);
17
            unlink($pathExec.'/newdep');
18
            chmod($pathExec."/dep",0755);
19
        } catch (\Exception $e){
20
            return false;
21
        }
22
23
        return true;
24
    }
25
}