Completed
Push — master ( c7c88d...7873ee )
by Mike
02:24
created

AbstractGetFileEntryPoint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 5 1
A downloadTo() 0 4 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
    public function __construct($url, array $options = array()) {
18
        $this->setRequest(new GETFile());
19
        parent::__construct($url, $options);
20
    }
21
22
    public function execute($data = null) {
23
        parent::execute($data);
24
        $this->setResponse(new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir));
25
        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
    public function downloadTo($path){
34
        $this->downloadDir = $path;
35
        return $this;
36
    }
37
38
}