Passed
Push — master ( d2190f...e6812d )
by Mihail
05:34
created

FormWallPostDelete::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Apps\Model\Front\Profile;
4
5
use Apps\ActiveRecord\WallPost;
6
use Ffcms\Core\Arch\Model;
7
use Ffcms\Core\Exception\ForbiddenException;
8
9
/**
10
 * Class FormWallPostDelete. Delete wall post business logic model
11
 * @package Apps\Model\Front\Profile
12
 */
13
class FormWallPostDelete extends Model
14
{
15
    public $id;
16
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->getAnswer()->delete();
43
        $this->_post->delete();
44
    }
45
46
47
}