Passed
Branch master (309757)
by Dispositif
03:20 queued 54s
created

PageOuvrageStore::getTableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 1
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019-2023 © Philippe M./Irønie  <[email protected]>
5
 * For the full copyright and MIT license information, view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
11
namespace App\Infrastructure;
12
13
use App\Domain\Models\PageOuvrageDTO;
14
use Simplon\Mysql\Crud\CrudStore;
15
use Simplon\Mysql\MysqlException;
16
use Simplon\Mysql\QueryBuilder\CreateQueryBuilder;
17
use Simplon\Mysql\QueryBuilder\DeleteQueryBuilder;
18
use Simplon\Mysql\QueryBuilder\ReadQueryBuilder;
19
use Simplon\Mysql\QueryBuilder\UpdateQueryBuilder;
20
21
class PageOuvrageStore extends CrudStore
22
{
23
    public function getTableName(): string
24
    {
25
        return 'page_ouvrages';
26
    }
27
28
    public function getModel(): PageOuvrageDTO
29
    {
30
        return new PageOuvrageDTO();
31
    }
32
33
    /**
34
     * @throws MysqlException
35
     */
36
    public function create(CreateQueryBuilder $builder): PageOuvrageDTO
37
    {
38
        /** @var PageOuvrageDTO $model */
39
        $model = $this->crudCreate($builder);
40
41
        return $model;
42
    }
43
44
    /**
45
     * @return PageOuvrageDTO[]|null
46
     * @throws MysqlException
47
     */
48
    public function read(?ReadQueryBuilder $builder = null): ?array
49
    {
50
        /** @var PageOuvrageDTO[]|null $response */
51
        $response = $this->crudRead($builder);
52
53
        return $response;
54
    }
55
56
    /**
57
     * @throws MysqlException
58
     */
59
    public function readOne(ReadQueryBuilder $builder): ?PageOuvrageDTO
60
    {
61
        /** @var PageOuvrageDTO|null $response */
62
        $response = $this->crudReadOne($builder);
63
64
        return $response;
65
    }
66
67
    /**
68
     * @throws MysqlException
69
     */
70
    public function update(UpdateQueryBuilder $builder): PageOuvrageDTO
71
    {
72
        /** @var PageOuvrageDTO|null $model */
73
        $model = $this->crudUpdate($builder);
74
75
        return $model;
76
    }
77
78
    /**
79
     * @throws MysqlException
80
     */
81
    public function delete(DeleteQueryBuilder $builder): bool
82
    {
83
        return $this->crudDelete($builder);
84
    }
85
86
//    /**
87
//     * @throws MysqlException
88
//     */
89
//    public function customMethod(int $id): ?PageOuvrageDTO
90
//    {
91
//        $query = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id=:id';
92
//
93
//        if ($result = $this->getCrudManager()->getMysql()->fetchRow($query, ['id' => $id]))
94
//        {
95
//            return (new PageOuvrageDTO())->fromArray($result);
96
//        }
97
//
98
//        return null;
99
//    }
100
}