FormContentRestore   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A labels() 0 4 1
A __construct() 0 4 1
A make() 0 3 1
A before() 0 4 1
1
<?php
2
3
namespace Apps\Model\Admin\Content;
4
5
use Apps\ActiveRecord\Content;
6
use Ffcms\Core\Arch\Model;
7
8
/**
9
 * Class FormContentRestore. Restore deleted content item from active record trash state
10
 * @package Apps\Model\Admin\Content
11
 */
12
class FormContentRestore extends Model
13
{
14
    public $id;
15
    public $title;
16
17
    private $_record;
18
19
    /**
20
     * FormContentRestore constructor. Pass active record object inside
21
     * @param Content $record
22
     */
23
    public function __construct(Content $record)
24
    {
25
        $this->_record = $record;
26
        parent::__construct();
27
    }
28
29
    /**
30
     * Set public attributes from active record object
31
     */
32
    public function before()
33
    {
34
        $this->id = $this->_record->id;
35
        $this->title = $this->_record->getLocaled('title');
36
    }
37
38
    /**
39
     * Form display labels
40
     * @return array
41
     */
42
    public function labels(): array
43
    {
44
        return [
45
            'title' => __('Title')
46
        ];
47
    }
48
49
    /**
50
     * Make restore of trashed item
51
     */
52
    public function make()
53
    {
54
        $this->_record->restore();
55
    }
56
}
57