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

AbstractGetFileEntryPoint::downloadTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 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
}