TypeAddModel::add()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 1
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Rudolf\Modules\Appearance\Menu\Type;
4
5
use Rudolf\Component\Html\Text;
6
use Rudolf\Framework\Model\AdminModel;
7
8
class TypeAddModel extends AdminModel
9
{
10
11
    public function add(array $p)
12
    {
13
        $stmt = $this->pdo->prepare("INSERT INTO {$this->prefix}menu_types SET 
14
          title = :title, description = :description, menu_type = :menu_type");
15
        $stmt->bindValue(':title', $p['title']);
16
        $stmt->bindValue(':description', $p['description']);
17
        $stmt->bindValue(':menu_type', Text::sluger(empty($p['menu_type']) ? $p['title'] : $p['menu_type']));
18
19
        $stmt->execute();
20
21
        return $this->pdo->lastInsertId();
22
    }
23
}
24