FormWallPostDelete   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 0 4 1
A before() 0 3 1
1
<?php
2
3
namespace Apps\Model\Front\Profile;
4
5
use Apps\ActiveRecord\WallPost;
6
use Ffcms\Core\Arch\Model;
7
8
/**
9
 * Class FormWallPostDelete. Delete wall post business logic model
10
 * @package Apps\Model\Front\Profile
11
 */
12
class FormWallPostDelete extends Model
13
{
14
    public $id;
15
16
    /** @var WallPost */
17
    private $_post;
18
19
    /**
20
     * FormWallPostDelete constructor. Pass wall post active record object inside model
21
     * @param WallPost $post
22
     */
23
    public function __construct(WallPost $post)
24
    {
25
        $this->_post = $post;
26
        parent::__construct();
27
    }
28
29
    /**
30
     * Set post id based on post active record
31
     */
32
    public function before()
33
    {
34
        $this->id = $this->_post->id;
35
    }
36
37
    /**
38
     * Delete wall post object from db
39
     */
40
    public function make()
41
    {
42
        $this->_post->answers()->delete();
43
        $this->_post->delete();
44
    }
45
}
46