Passed
Push — master ( 5f3f82...d9b525 )
by Mike
03:08
created

AbstractGetFileEntryPoint   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 1
cbo 4
dl 0
loc 38
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 5 1
A downloadTo() 0 4 1
A getDownloadDir() 0 3 1
1
<?php
2
3
namespace SugarAPI\SDK\EntryPoint\Abstracts\GET;
4
5
use SugarAPI\SDK\EntryPoint\Abstracts\AbstractEntryPoint;
6
use SugarAPI\SDK\Request\GETFile;
7
use SugarAPI\SDK\Response\File as FileResponse;
8
9
abstract class AbstractGetFileEntryPoint extends AbstractEntryPoint {
10
11
    /**
12
     * The directory in which to download the File
13
     * @var string
14
     */
15
    protected $downloadDir = null;
16
17 1
    public function __construct($url, array $options = array()){
18 1
        $this->setRequest(new GETFile());
19 1
        parent::__construct($url, $options);
20 1
    }
21
22 1
    public function execute($data = null){
23 1
        parent::execute($data);
24 1
        $this->setResponse(new FileResponse($this->Request->getResponse(), $this->Request->getCurlObject(), $this->downloadDir));
25 1
        return $this;
26
    }
27
28
    /**
29
     * Set the download directory for the File the EntryPoint is retrieving
30
     * @param $path
31
     * @return $this
32
     */
33 1
    public function downloadTo($path){
34 1
        $this->downloadDir = $path;
35 1
        return $this;
36
    }
37
38
    /**
39
     * Get the download directory for the File the EntryPoint is retrieving
40
     * @return string
41
     */
42 1
    public function getDownloadDir(){
43 1
        return $this->downloadDir;
44
    }
45
46
}