TestModel::upload()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 0
1
<?php
2
namespace RazonYang\Yii2\Uploader\Tests;
3
4
use RazonYang\Yii2\Uploader\UploadModelTrait;
5
use yii\base\Model;
6
use yii\web\ForbiddenHttpException;
7
8
class TestModel extends Model
9
{
10
    use UploadModelTrait;
0 ignored issues
show
Bug introduced by
The trait RazonYang\Yii2\Uploader\UploadModelTrait requires the property $tempName which is not provided by RazonYang\Yii2\Uploader\Tests\TestModel.
Loading history...
11
12
    public function upload()
13
    {
14
        if (!$this->validate()) {
15
            throw new ForbiddenHttpException('invalid file');
16
        }
17
        
18
        $url = UploadModelTrait::upload();
19
        return [
20
            'filename' => basename($url),
21
            'url' => $url,
22
        ];
23
    }
24
}
25