Passed
Push — main ( 7bc5d9...172c86 )
by Dimitri
11:51
created

ResourceController::setFormat()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Controllers;
13
14
/**
15
 * Un contrôleur extensible pour fournir une API RESTful pour une ressource.
16
 */
17
class ResourceController extends RestController
18
{
19
    /**
20
     * Renvoie un tableau d'objets ressources, eux-mêmes au format tableau
21
     *
22
     * @return \Psr\Http\Message\ResponseInterface|string|void
23
     */
24
    public function index()
25
    {
26
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
27
    }
28
29
    /**
30
     * Renvoyer les propriétés d'un objet ressource
31
     *
32
     * @param int|string|null $id
33
     *
34
     * @return \Psr\Http\Message\ResponseInterface|string|void
35
     */
36
    public function show($id = null)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

36
    public function show(/** @scrutinizer ignore-unused */ $id = null)

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

Loading history...
37
    {
38
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
39
    }
40
41
    /**
42
     * Renvoie un nouvel objet ressource, avec les propriétés par défaut
43
     *
44
     * @return \Psr\Http\Message\ResponseInterface|string|void
45
     */
46
    public function new()
47
    {
48
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
49
    }
50
51
    /**
52
     * Créer un nouvel objet ressource, à partir des données envoyées
53
     *
54
     * @return \Psr\Http\Message\ResponseInterface|string|void
55
     */
56
    public function create()
57
    {
58
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
59
    }
60
61
    /**
62
     * Renvoyer les propriétés modifiables d'un objet ressource
63
     *
64
     * @param int|string|null $id
65
     *
66
     * @return \Psr\Http\Message\ResponseInterface|string|void
67
     */
68
    public function edit($id = null)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

68
    public function edit(/** @scrutinizer ignore-unused */ $id = null)

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

Loading history...
69
    {
70
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
71
    }
72
73
    /**
74
     * Ajouter ou mettre à jour une ressource de modèle, à partir de données envoyées
75
     *
76
     * @param int|string|null $id
77
     *
78
     * @return \Psr\Http\Message\ResponseInterface|string|void
79
     */
80
    public function update($id = null)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

80
    public function update(/** @scrutinizer ignore-unused */ $id = null)

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

Loading history...
81
    {
82
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
83
    }
84
85
    /**
86
     * Supprimer l'objet ressource désigné du modèle
87
     *
88
     * @param int|string|null $id
89
     *
90
     * @return \Psr\Http\Message\ResponseInterface|string|void
91
     */
92
    public function delete($id = null)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

92
    public function delete(/** @scrutinizer ignore-unused */ $id = null)

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

Loading history...
93
    {
94
        return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__]));
95
    }
96
97
    /**
98
     * Définir/modifier la représentation de réponse attendue pour les objets renvoyés
99
     *
100
     * @param string $format json/xml
101
     *
102
     * @return void
103
     */
104
    public function setFormat(string $format = 'json')
105
    {
106
        if (in_array($format, ['json', 'xml'], true)) {
107
            $this->returnFormat($format);
108
        }
109
    }
110
}
111