File::onView()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Terranet\Administrator\Field;
4
5
use Terranet\Administrator\Scaffolding;
6
7
class File extends Field
8
{
9
    protected $visibility = [
10
        Scaffolding::PAGE_INDEX => true,
11
        Scaffolding::PAGE_EDIT => true,
12
        Scaffolding::PAGE_VIEW => true,
13
    ];
14
15
    /**
16
     * @return array
17
     */
18
    public function onEdit(): array
19
    {
20
        return $this->onIndex();
21
    }
22
23
    /**
24
     * @return array
25
     */
26
    public function onView(): array
27
    {
28
        return $this->onIndex();
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    protected function onIndex(): array
35
    {
36
        return [
37
            'attachment' => $this->model ? $this->model->{$this->id} : null,
38
        ];
39
    }
40
}
41