ArticleMapper::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Article\Mapper;
6
7
use Zend\Db\Adapter\Adapter;
8
use Zend\Db\Adapter\AdapterAwareInterface;
9
use Zend\Db\Sql\Delete;
10
use Zend\Db\Sql\Insert;
11
use Zend\Db\TableGateway\AbstractTableGateway;
12
13
/**
14
 * Class ArticleMapper.
15
 */
16
class ArticleMapper extends AbstractTableGateway implements AdapterAwareInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $table = 'articles';
22
23
    /**
24
     * Db adapter setter method,.
25
     *
26
     * @param Adapter $adapter db adapter
27
     *
28
     * @return void
29
     */
30
    public function setDbAdapter(Adapter $adapter)
31
    {
32
        $this->adapter = $adapter;
33
    }
34
35
    public function fetchAll($params)
36
    {
37
        return $this->select($params);
38
    }
39
40
    public function create($articleData)
41
    {
42
        $this->insert($articleData);
43
    }
44
45
    public function getCategories($articleId)
46
    {
47
        $select = $this->getSql()->select()
48
            ->columns([])
49
            ->join('category', 'category.category_uuid = articles.category_uuid', ['name', 'slug', 'category_id'])
50
            ->where(['articles.article_id' => $articleId]);
51
52
        return $this->selectWith($select);
53
    }
54
55
    /**
56
     * Delete all categories for given article.
57
     */
58
    public function deleteCategories($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
        trigger_error('Do not use anymore 01!', E_USER_NOTICE);
61
    }
62
63
    /**
64
     * @todo Refactore it - do a multi insert into MySQL
65
     */
66
    public function insertCategories($categories, $articleId)
0 ignored issues
show
Unused Code introduced by
The parameter $categories is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $articleId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
67
    {
68
        trigger_error('Do not use anymore 02!', E_USER_NOTICE);
69
    }
70
}
71