MediaScanTypeDAO   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllMediaScanTypes() 0 24 2
A updateMediaScanType() 0 9 1
A deleteMediaScanType() 0 9 1
A __construct() 0 2 1
A addMediaScanType() 0 9 1
1
<?php
2
namespace AL\Common\DAO;
3
4
require_once __DIR__."/../../lib/Db.php" ;
5
require_once __DIR__."/../Model/Dump/MediaScanType.php" ;
6
7
/**
8
 * DAO for Media Scan Type
9
 */
10
class MediaScanTypeDAO {
11
    private $mysqli;
12
13
    public function __construct($mysqli) {
14
        $this->mysqli = $mysqli;
15
    }
16
17
    /**
18
     * Get all Media Scan Types
19
     *
20
     * @return \AL\Common\Model\Dump\MediaType[] An array of media types
21
     */
22
    public function getAllMediaScanTypes() {
23
        $stmt = \AL\Db\execute_query(
24
            "MediaScanTypeDAO: getAllMediaScanTypes",
25
            $this->mysqli,
26
            "SELECT id, name FROM media_scan_type ORDER BY name",
27
            null, null
28
        );
29
30
        \AL\Db\bind_result(
31
            "MediaScanTypeDAO: getAllMediaScanTypes",
32
            $stmt,
33
            $id, $name
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $name seems to be never defined.
Loading history...
34
        );
35
36
        $media_scan_types = [];
37
        while ($stmt->fetch()) {
38
            $media_scan_types[] = new \AL\Common\Model\Dump\MediaScanType(
39
                $id, $name
40
            );
41
        }
42
43
        $stmt->close();
44
45
        return $media_scan_types;
46
    }
47
48
     /**
49
     * add a media scan type to the database
50
     *
51
     * @param varchar media_type
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\media_type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
52
     */
53
    public function addMediaScanType($media_scan_type) {
54
        $stmt = \AL\Db\execute_query(
55
            "MediaScanTypeDAO: addMediaScanType",
56
            $this->mysqli,
57
            "INSERT INTO media_scan_type (`name`) VALUES (?)",
58
            "s", $media_scan_type
59
        );
60
61
        $stmt->close();
62
    }
63
    
64
    /**
65
     * delete a media_scan_type
66
     *
67
     * @param int $media_scan_type_id
68
     */
69
    public function deleteMediaScanType($media_scan_type_id) {
70
        $stmt = \AL\Db\execute_query(
71
            "MediaScanTypeDAO: deleteScanMediaType",
72
            $this->mysqli,
73
            "DELETE FROM media_scan_type WHERE id = ?",
74
            "i", $media_scan_type_id
75
        );
76
77
        $stmt->close();
78
    }
79
    
80
        /**
81
     * update a media_scan_type
82
     *
83
     * @param int media_scan_type_id
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\media_scan_type_id was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
84
     * @param varchar media_scan_type
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\media_scan_type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
85
     */
86
    public function updateMediaScanType($media_scan_type_id, $media_scan_type_name) {
87
        $stmt = \AL\Db\execute_query(
88
            "MediaScanTypeDAO: updateMediaScanType",
89
            $this->mysqli,
90
            "UPDATE media_scan_type SET name = ? WHERE id = ?",
91
            "si", $media_scan_type_name, $media_scan_type_id
92
        );
93
        
94
        $stmt->close();
95
    }
96
}
97