FileDownloadTrait::download()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace yiicod\fileupload\models\traits;
4
5
use Yii;
6
7
/**
8
 * Coco trait uploader
9
 *
10
 * @author Orlov Alexey <[email protected]>
11
 */
12
trait FileDownloadTrait
13
{
14
    /**
15
     * Download
16
     *
17
     * @param $fileName
18
     * @param $filePath
19
     */
20
    public static function download(string $fileName, string $filePath)
21
    {
22
        if (file_exists($filePath)) {
23
            Yii::$app->response->sendFile($filePath, $fileName);
24
        }
25
    }
26
}
27