Passed
Push — master ( 336a24...a4f66d )
by Mihail
14:10
created

FormContentGlobDelete   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 1
cbo 3
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A before() 0 11 2
A make() 0 6 2
1
<?php
2
3
namespace Apps\Model\Admin\Content;
4
5
6
use Ffcms\Core\Arch\Model;
7
use Ffcms\Core\Helper\Date;
8
use Ffcms\Core\Helper\Serialize;
9
10
class FormContentGlobDelete extends Model
11
{
12
    private $_records;
13
14
    public $data = [];
15
16
    public function __construct($records)
17
    {
18
        $this->_records = $records;
19
        parent::__construct();
20
    }
21
22
    public function before()
23
    {
24
        // set data to display in view
25
        foreach ($this->_records as $row) {
26
            $this->data[] = [
27
                'id' => $row->id,
28
                'title' => Serialize::getDecodeLocale($row->title),
29
                'date' => Date::convertToDatetime($row->created_at, Date::FORMAT_TO_HOUR)
30
            ];
31
        }
32
    }
33
34
    public function make()
35
    {
36
        foreach ($this->_records as $record) {
37
            $record->delete();
38
        }
39
    }
40
41
42
}