From 30eccaa0e9c3ce194b6e63b81d0db8b427c5638c Mon Sep 17 00:00:00 2001 From: Lucas Mascaro Date: Thu, 10 Dec 2015 11:46:29 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20v=C3=A9rificationd=20e=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coverage/StaticRepo.php.html | 114 ++++---- coverage/dashboard.html | 30 ++- coverage/index.html | 42 +-- coverage/repos/MedecinRepo.php.html | 125 ++++----- coverage/repos/PatientRepo.php.html | 388 +++++++++++++++------------- coverage/repos/RDVRepo.php.html | 283 ++++++++++---------- coverage/repos/StatsRepo.php.html | 2 +- coverage/repos/dashboard.html | 22 +- coverage/repos/index.html | 60 ++--- repositories/StaticRepo.php | 8 + repositories/repos/MedecinRepo.php | 11 +- repositories/repos/PatientRepo.php | 34 ++- repositories/repos/RDVRepo.php | 17 +- test.php | 2 +- test/StaticRepoTest.php | 8 + 15 files changed, 633 insertions(+), 513 deletions(-) diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html index 48717c9..4e5ab09 100755 --- a/coverage/StaticRepo.php.html +++ b/coverage/StaticRepo.php.html @@ -60,13 +60,13 @@
2 / 4
CRAP
-
- 86.96% covered (warning) +
+ 84.62% covered (warning)
-
86.96%
-
40 / 46
+
84.62%
+
44 / 52
@@ -87,15 +87,15 @@
50.00%
2 / 4
- 38.88 + 48.42
-
- 86.96% covered (warning) +
+ 84.62% covered (warning)
-
86.96%
-
40 / 46
+
84.62%
+
44 / 52
@@ -171,15 +171,15 @@
0.00%
0 / 1
- 23.76 + 33.17
-
- 84.62% covered (warning) +
+ 81.25% covered (warning)
-
84.62%
-
22 / 26
+
81.25%
+
26 / 32
@@ -201,13 +201,13 @@
12
     * @return PDO instance de la connexion a la BDD
13
     */
14
    public static function getConnexion(){ -
15
        if(static::$config == null){ +
15
        if(static::$config == null){
16
            static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true);
17
        } -
18
        if(static::$connexion == null){ +
18
        if(static::$connexion == null){
19
            static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']);
20
        } -
21
        return static::$connexion; +
21
        return static::$connexion;
22
    }
23
24
    /** @@ -230,21 +230,21 @@
41
    public static function delNumeric($fetchData, $oneDimension=false){
42
    
43
    // cas où fetch renvoie FALSE -
44
    if( $fetchData === false ) return false; +
44
    if( $fetchData === false ) return false;
45
46
        /* [1] 2 dimensions
47
        ===============================================*/ -
48
        if( !$oneDimension ){ +
48
        if( !$oneDimension ){
49
50
        // on supprime les doublons des entrées (indice numérique) -
51
        for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs -
52
            foreach($fetchData[$i] as $col => $val){  // pour toutes les entrées +
51
        for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs +
52
            foreach($fetchData[$i] as $col => $val){  // pour toutes les entrées
53
                 -
54
                if( !mb_detect_encoding($val, 'UTF-8') ) +
54
                if( !mb_detect_encoding($val, 'UTF-8') )
55
                    $fetchData[$i][$col] = utf8_encode($val);
56
                 -
57
                if( is_int($col) )                    // si l'indice est un entier -
58
                    unset( $fetchData[$i][$col] );    // on le supprime +
57
                if( is_int($col) )                    // si l'indice est un entier +
58
                    unset( $fetchData[$i][$col] );    // on le supprime
59
            }
60
61
        /* [2] 1 dimensions @@ -263,7 +263,7 @@
74
75
        }
76
-
77
        return $fetchData; +
77
        return $fetchData;
78
    }
79
80
@@ -291,33 +291,33 @@
102
    public static function checkParam($variable, $dbtype){
103
        /* [1] on vérifie que $dbtype est un String
104
        =============================================================*/ -
105
        if( !is_string($dbtype) ) return false; +
105
        if( !is_string($dbtype) ) return false;
106
107
108
        /* [2] Vérifications
109
        =============================================================*/ -
110
        $checker = true; // contiendra VRAI si la vérification s'avère correcte -
111
        $matches = []; +
110
        $checker = true; // contiendra VRAI si la vérification s'avère correcte +
111
        $matches = [];
112
        //si on a un type scalairexlongueur, on traite -
113
        if(preg_match_all('/((?:[a-z][a-z]+))(\\d+)/is',$dbtype,$matches)){ -
114
            $dbtype = $matches[1][0]; -
115
            isset($matches[2][0])? $len = $matches[2][0] : $len = 8; +
113
        if(preg_match_all('/((?:[a-z][a-z]+))(\\d+)/is',$dbtype,$matches)){ +
114
            $dbtype = $matches[1][0]; +
115
            isset($matches[2][0])? $len = $matches[2][0] : $len = 8;
116
        }
117
118
        switch($dbtype){
119
            // [1] 'M' / 'F'  -
120
            case 'Civilite': -
121
                $checker = $checker && is_string($variable) && in_array($variable,['M','F']); -
122
                break; +
120
            case 'Civilite': +
121
                $checker = $checker && is_string($variable) && in_array($variable,['M','F']); +
122
                break;
123
124
            // [2] Chaine de caractère (longueur variable)
125
            case 'String': -
126
                $checker = $checker && is_string($variable) && strlen($variable)<$len; -
127
                break; +
126
                $checker = $checker && is_string($variable) && strlen($variable)<$len; +
127
                break;
128
129
            case 'Integer': -
130
                $checker = $checker && is_int($variable) && $variable<pow(2,32); -
131
                break; +
130
                $checker = $checker && is_int($variable) && $variable<pow(2,32); +
131
                break;
132
133
            case 'SmallInteger':
134
                $checker = $checker && is_int($variable) && $variable<pow(2,16); @@ -327,25 +327,33 @@
138
                $checker = $checker && is_int($variable) && $variable<pow(2,8);
139
                break;
140
-
141
            case 'BigInteger': +
141
            case 'BigInteger':
142
                $checker = $checker && is_int($variable) && $variable<pow(2,64);
143
                break;
144
-
145
            // [N] Type inconnu -
146
            default: $checker = false; break; -
147
        } +
145
            case 'Date': +
146
                $checker = $checker && is_string($variable) && preg_match('/(\d+)\/(\d+)\/(\d+)/is',$variable); +
147
                break;
148
-
149
-
150
        /* [3] On retourne le résultat de la vérif -
151
        =============================================================*/ -
152
        return $checker; -
153
-
154
    } -
155
+
149
            case 'Heure': +
150
                $checker = $checker && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable); +
151
                break; +
152
+
153
            // [N] Type inconnu +
154
            default: $checker = false; break; +
155
        }
156
-
157
} -
158
-
159
?> +
157
+
158
        /* [3] On retourne le résultat de la vérif +
159
        =============================================================*/ +
160
        return $checker; +
161
+
162
    } +
163
+
164
+
165
} +
166
+
167
?> @@ -358,7 +366,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/coverage/dashboard.html b/coverage/dashboard.html index 40c609b..dbaded8 100755 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -58,7 +58,8 @@ - StaticRepo86% + StaticRepo84% + RDVRepo85% @@ -75,7 +76,8 @@ - StaticRepo38 + StaticRepo48 + RDVRepo19 @@ -113,11 +115,11 @@ - checkParam84% + getByDate20% + checkParam81% delNumeric85% - add85% - getAll85% - add88% + getAll85% + add88% @@ -134,11 +136,11 @@ - checkParam23 + checkParam33 delNumeric10 add5 - getAll4 - add2 + getByDate4 + getAll4 @@ -148,7 +150,7 @@
@@ -169,7 +171,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,4,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,2,3,0], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -187,7 +189,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,5,3,18], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,1,0,0,0,0,0,4,4,17], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -237,7 +239,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[86.95652173913,36,"StaticRepo<\/a>"],[95.833333333333,12,"MedecinRepo<\/a>"],[95.652173913043,9,"PatientRepo<\/a>"],[92.682926829268,11,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[84.615384615385,42,"StaticRepo<\/a>"],[96.428571428571,15,"MedecinRepo<\/a>"],[96.875,39,"PatientRepo<\/a>"],[85.106382978723,18,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -261,7 +263,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[84.615384615385,22,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[85.714285714286,5,"MedecinRepo::add<\/a>"],[100,1,"MedecinRepo::delete<\/a>"],[100,1,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"PatientRepo::getById<\/a>"],[93.75,2,"PatientRepo::add<\/a>"],[94.444444444444,2,"PatientRepo::update<\/a>"],[100,1,"PatientRepo::delete<\/a>"],[100,1,"PatientRepo::updateMedecinTraitant<\/a>"],[100,1,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,1,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getByDate<\/a>"],[100,1,"RDVRepo::delete<\/a>"],[88.888888888889,2,"RDVRepo::add<\/a>"],[100,1,"RDVRepo::updateDateTime<\/a>"],[100,1,"RDVRepo::getByPatientAndDate<\/a>"],[85.714285714286,4,"RDVRepo::getAll<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[81.25,28,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,3,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[95.652173913043,14,"PatientRepo::add<\/a>"],[96,14,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,3,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[20,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,1,"RDVRepo::updateDateTime<\/a>"],[100,1,"RDVRepo::getByPatientAndDate<\/a>"],[85.714285714286,4,"RDVRepo::getAll<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/index.html b/coverage/index.html index 277eb67..90c22c9 100755 --- a/coverage/index.html +++ b/coverage/index.html @@ -43,21 +43,21 @@ Total
-
- 92.35% covered (success) +
+ 90.78% covered (success)
-
92.35%
-
169 / 183
+
90.78%
+
197 / 217
-
- 69.23% covered (warning) +
+ 65.38% covered (warning)
-
69.23%
-
18 / 26
+
65.38%
+
17 / 26
0.00% covered (danger) @@ -71,21 +71,21 @@ repos
-
- 94.16% covered (success) +
+ 92.73% covered (success)
-
94.16%
-
129 / 137
+
92.73%
+
153 / 165
-
- 72.73% covered (warning) +
+ 68.18% covered (warning)
-
72.73%
-
16 / 22
+
68.18%
+
15 / 22
0.00% covered (danger) @@ -99,13 +99,13 @@ StaticRepo.php
-
- 86.96% covered (warning) +
+ 84.62% covered (warning)
-
86.96%
-
40 / 46
+
84.62%
+
44 / 52
50.00% covered (danger) @@ -136,7 +136,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/coverage/repos/MedecinRepo.php.html b/coverage/repos/MedecinRepo.php.html index cc941fd..644839d 100755 --- a/coverage/repos/MedecinRepo.php.html +++ b/coverage/repos/MedecinRepo.php.html @@ -61,13 +61,13 @@
5 / 6
CRAP
-
- 95.83% covered (success) +
+ 96.43% covered (success)
-
95.83%
-
23 / 24
+
96.43%
+
27 / 28
@@ -88,15 +88,15 @@
83.33%
5 / 6
- 12 + 15
-
- 95.83% covered (success) +
+ 96.43% covered (success)
-
95.83%
-
23 / 24
+
96.43%
+
27 / 28
@@ -130,19 +130,19 @@
0.00%
0 / 1
- 5.07 + 5.03
-
- 85.71% covered (warning) +
+ 88.89% covered (warning)
-
85.71%
-
6 / 7
+
88.89%
+
8 / 9
-  delete +  delete
100.00% covered (success) @@ -151,7 +151,7 @@
100.00%
1 / 1
- 1 + 2
100.00% covered (success) @@ -159,11 +159,11 @@
100.00%
-
2 / 2
+
3 / 3
-  search +  search
100.00% covered (success) @@ -172,7 +172,7 @@
100.00%
1 / 1
- 1 + 3
100.00% covered (success) @@ -180,11 +180,11 @@
100.00%
-
4 / 4
+
5 / 5
-  getPatients +  getPatients
100.00% covered (success) @@ -205,7 +205,7 @@ -  getAll +  getAll
100.00% covered (success) @@ -259,44 +259,53 @@         $result = $req->execute(['civilite' => $civilite,             'nom' => $nom,             'prenom' => $prenom]); -         if($result != false){return StaticRepo::getConnexion()->lastInsertId();} -         else{return false;} -     } - -     public static function delete($idMedecin){ -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); -         return $req->execute(['id' => $idMedecin]); -     } +         //PDO renvoie un ID sous forme de char, on transtype +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id,'integer'); +         if($result){return $id;} +         else{return false;} +     } + +     public static function delete($idMedecin){ -     public static function search($nom,$prenom){ -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); -         $req->execute(['nom' => $nom, -             'prenom' => $prenom]); - -         return StaticRepo::delNumeric($req->fetchAll()); -     } +         if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); +         return $req->execute(['id' => $idMedecin]); +     } + +     public static function search($nom,$prenom){ -     public static function getPatients($idMedecin){ +         if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} -         if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;} - -         $req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin -                     WHERE Medecin.Id = :id -                     AND Medecin.Id = Patient.MedecinTraitant'); - -         $req->execute(['id' => $idMedecin]); -         return StaticRepo::delNumeric($req->fetchAll()); -     } - -     public static function getAll(){ - -         $req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC'); - -         return StaticRepo::delNumeric( $req->fetchAll() ); - -     } - - } +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); +         $req->execute(['nom' => $nom, +             'prenom' => $prenom]); + +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function getPatients($idMedecin){ + +         if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin +                     WHERE Medecin.Id = :id +                     AND Medecin.Id = Patient.MedecinTraitant'); + +         $req->execute(['id' => $idMedecin]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function getAll(){ + +         $req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC'); + +         return StaticRepo::delNumeric( $req->fetchAll() ); + +     } + + } @@ -309,7 +318,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/coverage/repos/PatientRepo.php.html b/coverage/repos/PatientRepo.php.html index 0533854..590790d 100755 --- a/coverage/repos/PatientRepo.php.html +++ b/coverage/repos/PatientRepo.php.html @@ -61,13 +61,13 @@
5 / 7
CRAP
-
- 95.65% covered (success) +
+ 96.88% covered (success)
-
95.65%
-
44 / 46
+
96.88%
+
62 / 64
@@ -88,15 +88,15 @@
71.43%
5 / 7
- 9 + 39
-
- 95.65% covered (success) +
+ 96.88% covered (success)
-
95.65%
-
44 / 46
+
96.88%
+
62 / 64
@@ -109,7 +109,70 @@
100.00%
1 / 1
- 1 + 2 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
4 / 4
+ + + +  add +
+
+ 0.00% covered (danger) +
+
+ +
0.00%
+
0 / 1
+ 14 +
+
+ 95.65% covered (success) +
+
+ +
95.65%
+
22 / 23
+ + + +  update +
+
+ 0.00% covered (danger) +
+
+ +
0.00%
+
0 / 1
+ 14 +
+
+ 96.00% covered (success) +
+
+ +
96.00%
+
24 / 25
+ + + +  delete +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 2
100.00% covered (success) @@ -121,49 +184,7 @@ -  add -
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
- 2.00 -
-
- 93.75% covered (success) -
-
- -
93.75%
-
15 / 16
- - - -  update -
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
- 2.00 -
-
- 94.44% covered (success) -
-
- -
94.44%
-
17 / 18
- - - -  delete +  updateMedecinTraitant
100.00% covered (success) @@ -172,49 +193,7 @@
100.00%
1 / 1
- 1 -
-
- 100.00% covered (success) -
-
- -
100.00%
-
2 / 2
- - - -  updateMedecinTraitant -
-
- 100.00% covered (success) -
-
- -
100.00%
-
1 / 1
- 1 -
-
- 100.00% covered (success) -
-
- -
100.00%
-
2 / 2
- - - -  search -
-
- 100.00% covered (success) -
-
- -
100.00%
-
1 / 1
- 1 + 3
100.00% covered (success) @@ -226,7 +205,28 @@ -  getAll +  search +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 3 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
4 / 4
+ + + +  getAll
100.00% covered (success) @@ -262,95 +262,117 @@ class PatientRepo {     public static function getById($id){ - -         //if(!StaticRepo::checkParam($id,'Integer')){print_r(is_int($id));} - -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id'); -         $req->execute(['id' => $id]); -         return StaticRepo::delNumeric( $req->fetch(), true ); - -     } - -     public static function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ - -         $dateNaissance = strtotime($dateNaissance); -         $dateNaissance = Date('o-m-d',$dateNaissance); - -         $req = StaticRepo::getConnexion()->prepare('INSERT INTO Patient VALUES (DEFAULT,:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,:medecin)'); -         $result = $req->execute(['civilite' => $civilite, -             'nom' => $nom, -             'prenom' => $prenom, -             'adresse' => $adresse, -             'adresse2' => $adresse2, -             'ville' => $ville, -             'codePostal' => $codePostal, -             'dateNaissance' => $dateNaissance, -             'lieuNaissance' => $lieuNaissance, -             'numSecu' => $numSecu, -             'medecin' => $medecinTraitant ]); -         if($result){return StaticRepo::getConnexion()->lastInsertId();} -         else{return false;} - -     } - -     public static function update($id,$civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant){ -         $dateNaissance = strtotime($dateNaissance); -         $dateNaissance = Date('o-m-d',$dateNaissance); - -         $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET Civilite=:civilite,Nom=:nom,Prenom=:prenom,Adresse=:adresse,Adresse2=:adresse2,Ville=:ville, -         CodePostal=:codePostal,DateNaissance=:dateNaissance,LieuNaissance=:lieuNaissance,NumSecuriteSociale=:numSecu,MedecinTraitant=:medecin WHERE Id=:id;'); -         $result = $req->execute(['civilite' => $civilite, -             'nom' => $nom, -             'prenom' => $prenom, -             'adresse' => $adresse, -             'adresse2' => $adresse2, -             'ville' => $ville, -             'codePostal' => $codePostal, -             'dateNaissance' => $dateNaissance, -             'lieuNaissance' => $lieuNaissance, -             'numSecu' => $numSecu, -             'medecin' => $medecinTraitant, -             'id' => $id]); -         if($result){return StaticRepo::getConnexion()->lastInsertId();} -         else{return false;} +         if(!StaticRepo::checkParam($id,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id'); +         $req->execute(['id' => $id]); +         return StaticRepo::delNumeric( $req->fetch(), true ); + +     } + +     public static function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ + +         if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') +             && !StaticRepo::checkParam($adresse,'String255') && !StaticRepo::checkParam($adresse2,'String255')&& !StaticRepo::checkParam($ville,'String50') +             && !StaticRepo::checkParam($codePostal,'String5') && !StaticRepo::checkParam($dateNaissance,'Date') && !StaticRepo::checkParam($lieuNaissance,'String50') +             && !StaticRepo::checkParam($numSecu,'String15')){return false;} + +         if($medecinTraitant != null && !StaticRepo::checkParam($medecinTraitant,'Integer')){return false;} + +         $dateNaissance = strtotime($dateNaissance); +         $dateNaissance = Date('o-m-d',$dateNaissance); + +         $req = StaticRepo::getConnexion()->prepare('INSERT INTO Patient VALUES (DEFAULT,:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,:medecin)'); +         $result = $req->execute(['civilite' => $civilite, +             'nom' => $nom, +             'prenom' => $prenom, +             'adresse' => $adresse, +             'adresse2' => $adresse2, +             'ville' => $ville, +             'codePostal' => $codePostal, +             'dateNaissance' => $dateNaissance, +             'lieuNaissance' => $lieuNaissance, +             'numSecu' => $numSecu, +             'medecin' => $medecinTraitant ]); +         //PDO renvoie un ID sous forme de char, on transtype +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id,'integer'); +         if($result){return $id;} +         else{return false;} + +     } + +     public static function update($id,$civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant){ + +         if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') +             && !StaticRepo::checkParam($adresse,'String255') && !StaticRepo::checkParam($adresse2,'String255')&& !StaticRepo::checkParam($ville,'String50') +             && !StaticRepo::checkParam($codePostal,'String5') && !StaticRepo::checkParam($dateNaissance,'Date') && !StaticRepo::checkParam($lieuNaissance,'String50') +             && !StaticRepo::checkParam($numSecu,'String15')){return false;} + +         if($medecinTraitant != null && !StaticRepo::checkParam($medecinTraitant,'Integer')){return false;} + +         $dateNaissance = strtotime($dateNaissance); +         $dateNaissance = Date('o-m-d',$dateNaissance); -     } - -     public static function delete($idPatient){ - -         //if(!StaticRepo::checkParam($idPatient,'Integer')){ printf($idPatient);return false;} - -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); -         return $req->execute(['id' => $idPatient]); - -     } - -     public static function updateMedecinTraitant($idPatient,$idMedecin){ - -         //if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} - -         $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); -         return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); - -     } +         $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET Civilite=:civilite,Nom=:nom,Prenom=:prenom,Adresse=:adresse,Adresse2=:adresse2,Ville=:ville, +         CodePostal=:codePostal,DateNaissance=:dateNaissance,LieuNaissance=:lieuNaissance,NumSecuriteSociale=:numSecu,MedecinTraitant=:medecin WHERE Id=:id;'); +         $result = $req->execute(['civilite' => $civilite, +             'nom' => $nom, +             'prenom' => $prenom, +             'adresse' => $adresse, +             'adresse2' => $adresse2, +             'ville' => $ville, +             'codePostal' => $codePostal, +             'dateNaissance' => $dateNaissance, +             'lieuNaissance' => $lieuNaissance, +             'numSecu' => $numSecu, +             'medecin' => $medecinTraitant, +             'id' => $id]); +         //PDO renvoie un ID sous forme de char, on transtype +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id,'integer'); +         if($result){return $id;} +         else{return false;} -     public static function search($nom,$prenom){ +     } -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); -         $req->execute(['nom' => $nom, 'prenom' => $prenom]); -         return StaticRepo::delNumeric($req->fetchAll()); +     public static function delete($idPatient){ + +         if(!StaticRepo::checkParam($idPatient,'Integer')){ return false;} -     } - -     public static function getAll(){ - -         $req = StaticRepo::getConnexion()->query('SELECT * FROM Patient ORDER BY nom, prenom ASC'); - -         return StaticRepo::delNumeric( $req->fetchAll() ); - -     } - - } +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); +         return $req->execute(['id' => $idPatient]); + +     } + +     public static function updateMedecinTraitant($idPatient,$idMedecin){ + +         if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); +         return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); + +     } + +     public static function search($nom,$prenom){ + +         if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); +         $req->execute(['nom' => $nom, 'prenom' => $prenom]); +         return StaticRepo::delNumeric($req->fetchAll()); + +     } + +     public static function getAll(){ + +         $req = StaticRepo::getConnexion()->query('SELECT * FROM Patient ORDER BY nom, prenom ASC'); + +         return StaticRepo::delNumeric( $req->fetchAll() ); + +     } + + } @@ -363,7 +385,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/coverage/repos/RDVRepo.php.html b/coverage/repos/RDVRepo.php.html index 20da2c0..2967ba9 100755 --- a/coverage/repos/RDVRepo.php.html +++ b/coverage/repos/RDVRepo.php.html @@ -52,22 +52,22 @@
0.00%
0 / 1
-
- 71.43% covered (warning) +
+ 57.14% covered (warning)
-
71.43%
-
5 / 7
+
57.14%
+
4 / 7
CRAP -
-
- 92.68% covered (success) +
+
+ 85.11% covered (warning)
-
92.68%
-
38 / 41
+
85.11%
+
40 / 47
@@ -81,22 +81,22 @@
0.00%
0 / 1
-
- 71.43% covered (warning) +
+ 57.14% covered (warning)
-
71.43%
-
5 / 7
- 11.05 -
-
- 92.68% covered (success) +
57.14%
+
4 / 7
+ 19.07 +
+
+ 85.11% covered (warning)
-
92.68%
-
38 / 41
+
85.11%
+
40 / 47
@@ -109,7 +109,49 @@
100.00%
1 / 1
- 1 + 2 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
4 / 4
+ + + +  getByDate +
+
+ 0.00% covered (danger) +
+
+ +
0.00%
+
0 / 1
+ 4.05 +
+
+ 20.00% covered (danger) +
+
+ +
20.00%
+
1 / 5
+ + + +  delete +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 2
100.00% covered (success) @@ -121,49 +163,7 @@ -  getByDate -
-
- 100.00% covered (success) -
-
- -
100.00%
-
1 / 1
- 1 -
-
- 100.00% covered (success) -
-
- -
100.00%
-
4 / 4
- - - -  delete -
-
- 100.00% covered (success) -
-
- -
100.00%
-
1 / 1
- 1 -
-
- 100.00% covered (success) -
-
- -
100.00%
-
2 / 2
- - - -  add +  add
0.00% covered (danger) @@ -172,19 +172,19 @@
0.00%
0 / 1
- 2.01 -
-
- 88.89% covered (warning) + 6.02 +
+
+ 91.67% covered (success)
-
88.89%
-
8 / 9
+
91.67%
+
11 / 12
-  updateDateTime +  updateDateTime
100.00% covered (success) @@ -205,7 +205,7 @@ -  getByPatientAndDate +  getByPatientAndDate
100.00% covered (success) @@ -226,7 +226,7 @@ -  getAll +  getAll
0.00% covered (danger) @@ -263,72 +263,87 @@ {         public static function getById($id){ -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE RDV.id = :id'); -         $req->execute(['id' => $id]); -         return StaticRepo::delNumeric( $req->fetch(), true ); - -     } - -     public static function getByDate($date){ -         $date = date('Y-m-d',strtotime($date)); -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC'); -         $req->execute(['date' => $date]); -         return StaticRepo::delNumeric($req->fetchAll()); -     } + +         if(!StaticRepo::checkParam($id,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE RDV.id = :id'); +         $req->execute(['id' => $id]); +         return StaticRepo::delNumeric( $req->fetch(), true ); + +     } + +     public static function getByDate($date){ + +         if(!StaticRepo::checkParam($date,'Date')){return false;} -     public static function delete($idRDV){ -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); -         return $req->execute(['id' => $idRDV]); -     } - -     public static function add($date,$duree,$idPatient,$idMedecin){ -         $date = date('Y-m-d H:i:s',strtotime($date)); -         $duree = date('H:i:s',$duree*60); -         $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); -         $result = $req->execute(['date' => $date, -             'duree' => $duree, -             'patient' => $idPatient, -             'medecin' => $idMedecin]); +         $date = date('Y-m-d',strtotime($date)); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC'); +         $req->execute(['date' => $date]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function delete($idRDV){ + +         if(!StaticRepo::checkParam($idRDV,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); +         return $req->execute(['id' => $idRDV]); +     } -         if($result != false){return StaticRepo::getConnexion()->lastInsertId();} -         else{return false;} -     } +     public static function add($date,$duree,$idPatient,$idMedecin){ + +         if(!StaticRepo::checkParam($date,'Date') && !StaticRepo::checkParam($duree,'Integer') && !StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} -     public static function updateDateTime($idRDV,$dateTime){ -         $date = date('Y-m-d H:i:s',strtotime($dateTime)); -         $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); -         return $req->execute(['date' => $date, -             'id' => $idRDV]); -     } - -     public static function getByPatientAndDate($idPatient,$date){ -         $date = date('Y-m-d',strtotime($date)); -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date'); -         $req->execute(['patient' => $idPatient, -             'date' => $date]); -         return StaticRepo::delNumeric($req->fetchAll()); +         $date = date('Y-m-d H:i:s',strtotime($date)); +         $duree = date('H:i:s',$duree*60); +         $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); +         $result = $req->execute(['date' => $date, +             'duree' => $duree, +             'patient' => $idPatient, +             'medecin' => $idMedecin]); + +         //PDO renvoie un ID sous forme de char, on transtype +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id,'integer'); +         if($result){return $id;} +         else{return false;}     } -     public static function getAll($date = 0){ -         $dateTime = date('Y-m-d',time()); -         switch($date){ -             case -1: -                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) <= :date ORDER BY DateRDV ASC'); -                 $req->execute(['date' => $dateTime]); -                 break; -             case 0: -                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV ORDER BY DateRDV ASC'); -                 $req->execute(); -                 break; -             case 1: -                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) >= :date ORDER BY DateRDV ASC'); -                 $req->execute(['date' => $dateTime]); -                 break; -         } -         return StaticRepo::delNumeric($req->fetchAll()); -     } - - } +     public static function updateDateTime($idRDV,$dateTime){ +         $date = date('Y-m-d H:i:s',strtotime($dateTime)); +         $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); +         return $req->execute(['date' => $date, +             'id' => $idRDV]); +     } + +     public static function getByPatientAndDate($idPatient,$date){ +         $date = date('Y-m-d',strtotime($date)); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date'); +         $req->execute(['patient' => $idPatient, +             'date' => $date]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function getAll($date = 0){ +         $dateTime = date('Y-m-d',time()); +         switch($date){ +             case -1: +                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) <= :date ORDER BY DateRDV ASC'); +                 $req->execute(['date' => $dateTime]); +                 break; +             case 0: +                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV ORDER BY DateRDV ASC'); +                 $req->execute(); +                 break; +             case 1: +                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) >= :date ORDER BY DateRDV ASC'); +                 $req->execute(['date' => $dateTime]); +                 break; +         } +         return StaticRepo::delNumeric($req->fetchAll()); +     } + + } @@ -341,7 +356,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html index 59c7604..dd23b07 100755 --- a/coverage/repos/StatsRepo.php.html +++ b/coverage/repos/StatsRepo.php.html @@ -213,7 +213,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html index 8b92fa9..ce784c4 100755 --- a/coverage/repos/dashboard.html +++ b/coverage/repos/dashboard.html @@ -59,6 +59,7 @@ + RDVRepo85% @@ -75,6 +76,7 @@ + RDVRepo19 @@ -112,9 +114,9 @@ - add85% - getAll85% - add88% + getByDate20% + getAll85% + add88% @@ -132,8 +134,8 @@ add5 - getAll4 - add2 + getByDate4 + getAll4 @@ -143,7 +145,7 @@
@@ -164,7 +166,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,0,4,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,3,0], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -182,7 +184,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,3,3,16], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,1,0,0,0,0,0,2,4,15], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -232,7 +234,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[95.833333333333,12,"MedecinRepo<\/a>"],[95.652173913043,9,"PatientRepo<\/a>"],[92.682926829268,11,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[96.428571428571,15,"MedecinRepo<\/a>"],[96.875,39,"PatientRepo<\/a>"],[85.106382978723,18,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -256,7 +258,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,2,"MedecinRepo::getById<\/a>"],[85.714285714286,5,"MedecinRepo::add<\/a>"],[100,1,"MedecinRepo::delete<\/a>"],[100,1,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"PatientRepo::getById<\/a>"],[93.75,2,"PatientRepo::add<\/a>"],[94.444444444444,2,"PatientRepo::update<\/a>"],[100,1,"PatientRepo::delete<\/a>"],[100,1,"PatientRepo::updateMedecinTraitant<\/a>"],[100,1,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,1,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getByDate<\/a>"],[100,1,"RDVRepo::delete<\/a>"],[88.888888888889,2,"RDVRepo::add<\/a>"],[100,1,"RDVRepo::updateDateTime<\/a>"],[100,1,"RDVRepo::getByPatientAndDate<\/a>"],[85.714285714286,4,"RDVRepo::getAll<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,3,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[95.652173913043,14,"PatientRepo::add<\/a>"],[96,14,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,3,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[20,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,1,"RDVRepo::updateDateTime<\/a>"],[100,1,"RDVRepo::getByPatientAndDate<\/a>"],[85.714285714286,4,"RDVRepo::getAll<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/repos/index.html b/coverage/repos/index.html index 013dbc9..7a0134b 100755 --- a/coverage/repos/index.html +++ b/coverage/repos/index.html @@ -44,21 +44,21 @@ Total
-
- 94.16% covered (success) +
+ 92.73% covered (success)
-
94.16%
-
129 / 137
+
92.73%
+
153 / 165
-
- 72.73% covered (warning) +
+ 68.18% covered (warning)
-
72.73%
-
16 / 22
+
68.18%
+
15 / 22
0.00% covered (danger) @@ -72,13 +72,13 @@ MedecinRepo.php
-
- 95.83% covered (success) +
+ 96.43% covered (success)
-
95.83%
-
23 / 24
+
96.43%
+
27 / 28
83.33% covered (warning) @@ -100,13 +100,13 @@ PatientRepo.php
-
- 95.65% covered (success) +
+ 96.88% covered (success)
-
95.65%
-
44 / 46
+
96.88%
+
62 / 64
71.43% covered (warning) @@ -126,23 +126,23 @@ - RDVRepo.php -
-
- 92.68% covered (success) -
-
- -
92.68%
-
38 / 41
+ RDVRepo.php
-
- 71.43% covered (warning) +
+ 85.11% covered (warning)
-
71.43%
-
5 / 7
+
85.11%
+
40 / 47
+
+
+ 57.14% covered (warning) +
+
+ +
57.14%
+
4 / 7
0.00% covered (danger) @@ -193,7 +193,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:12:27 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 10:46:08 UTC 2015.

diff --git a/repositories/StaticRepo.php b/repositories/StaticRepo.php index b1a84f6..6c79c16 100755 --- a/repositories/StaticRepo.php +++ b/repositories/StaticRepo.php @@ -142,6 +142,14 @@ class StaticRepo{ $checker = $checker && is_int($variable) && $variableexecute(['civilite' => $civilite, 'nom' => $nom, 'prenom' => $prenom]); - if($result != false){return StaticRepo::getConnexion()->lastInsertId();} + //PDO renvoie un ID sous forme de char, on transtype + $id = StaticRepo::getConnexion()->lastInsertId(); + settype($id,'integer'); + if($result){return $id;} else{return false;} } public static function delete($idMedecin){ + + if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;} + $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); return $req->execute(['id' => $idMedecin]); } public static function search($nom,$prenom){ + + if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); $req->execute(['nom' => $nom, 'prenom' => $prenom]); diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index d97c628..740676e 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -9,8 +9,7 @@ class PatientRepo { public static function getById($id){ - - //if(!StaticRepo::checkParam($id,'Integer')){print_r(is_int($id));} + if(!StaticRepo::checkParam($id,'Integer')){return false;} $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id'); $req->execute(['id' => $id]); @@ -20,6 +19,13 @@ class PatientRepo public static function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ + if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') + && !StaticRepo::checkParam($adresse,'String255') && !StaticRepo::checkParam($adresse2,'String255')&& !StaticRepo::checkParam($ville,'String50') + && !StaticRepo::checkParam($codePostal,'String5') && !StaticRepo::checkParam($dateNaissance,'Date') && !StaticRepo::checkParam($lieuNaissance,'String50') + && !StaticRepo::checkParam($numSecu,'String15')){return false;} + + if($medecinTraitant != null && !StaticRepo::checkParam($medecinTraitant,'Integer')){return false;} + $dateNaissance = strtotime($dateNaissance); $dateNaissance = Date('o-m-d',$dateNaissance); @@ -35,12 +41,23 @@ class PatientRepo 'lieuNaissance' => $lieuNaissance, 'numSecu' => $numSecu, 'medecin' => $medecinTraitant ]); - if($result){return StaticRepo::getConnexion()->lastInsertId();} + //PDO renvoie un ID sous forme de char, on transtype + $id = StaticRepo::getConnexion()->lastInsertId(); + settype($id,'integer'); + if($result){return $id;} else{return false;} } public static function update($id,$civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant){ + + if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') + && !StaticRepo::checkParam($adresse,'String255') && !StaticRepo::checkParam($adresse2,'String255')&& !StaticRepo::checkParam($ville,'String50') + && !StaticRepo::checkParam($codePostal,'String5') && !StaticRepo::checkParam($dateNaissance,'Date') && !StaticRepo::checkParam($lieuNaissance,'String50') + && !StaticRepo::checkParam($numSecu,'String15')){return false;} + + if($medecinTraitant != null && !StaticRepo::checkParam($medecinTraitant,'Integer')){return false;} + $dateNaissance = strtotime($dateNaissance); $dateNaissance = Date('o-m-d',$dateNaissance); @@ -58,14 +75,17 @@ class PatientRepo 'numSecu' => $numSecu, 'medecin' => $medecinTraitant, 'id' => $id]); - if($result){return StaticRepo::getConnexion()->lastInsertId();} + //PDO renvoie un ID sous forme de char, on transtype + $id = StaticRepo::getConnexion()->lastInsertId(); + settype($id,'integer'); + if($result){return $id;} else{return false;} } public static function delete($idPatient){ - //if(!StaticRepo::checkParam($idPatient,'Integer')){ printf($idPatient);return false;} + if(!StaticRepo::checkParam($idPatient,'Integer')){ return false;} $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); return $req->execute(['id' => $idPatient]); @@ -74,7 +94,7 @@ class PatientRepo public static function updateMedecinTraitant($idPatient,$idMedecin){ - //if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} + if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); @@ -83,6 +103,8 @@ class PatientRepo public static function search($nom,$prenom){ + if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); $req->execute(['nom' => $nom, 'prenom' => $prenom]); return StaticRepo::delNumeric($req->fetchAll()); diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php index 3174f4b..8c8738d 100755 --- a/repositories/repos/RDVRepo.php +++ b/repositories/repos/RDVRepo.php @@ -10,6 +10,9 @@ class RDVRepo { public static function getById($id){ + + if(!StaticRepo::checkParam($id,'Integer')){return false;} + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE RDV.id = :id'); $req->execute(['id' => $id]); return StaticRepo::delNumeric( $req->fetch(), true ); @@ -17,6 +20,9 @@ class RDVRepo } public static function getByDate($date){ + + if(!StaticRepo::checkParam($date,'Date')){return false;} + $date = date('Y-m-d',strtotime($date)); $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC'); $req->execute(['date' => $date]); @@ -24,11 +30,17 @@ class RDVRepo } public static function delete($idRDV){ + + if(!StaticRepo::checkParam($idRDV,'Integer')){return false;} + $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); return $req->execute(['id' => $idRDV]); } public static function add($date,$duree,$idPatient,$idMedecin){ + + if(!StaticRepo::checkParam($date,'Date') && !StaticRepo::checkParam($duree,'Integer') && !StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} + $date = date('Y-m-d H:i:s',strtotime($date)); $duree = date('H:i:s',$duree*60); $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); @@ -37,7 +49,10 @@ class RDVRepo 'patient' => $idPatient, 'medecin' => $idMedecin]); - if($result != false){return StaticRepo::getConnexion()->lastInsertId();} + //PDO renvoie un ID sous forme de char, on transtype + $id = StaticRepo::getConnexion()->lastInsertId(); + settype($id,'integer'); + if($result){return $id;} else{return false;} } diff --git a/test.php b/test.php index 30c4dd3..5ae6bc4 100755 --- a/test.php +++ b/test.php @@ -7,4 +7,4 @@ */ require_once('autoloader.php'); -var_dump(RDVRepo::getAll(1)); \ No newline at end of file +var_dump(StaticRepo::checkParam(138,'Integer')); \ No newline at end of file diff --git a/test/StaticRepoTest.php b/test/StaticRepoTest.php index 8a0b9a3..7e9baa0 100755 --- a/test/StaticRepoTest.php +++ b/test/StaticRepoTest.php @@ -50,6 +50,14 @@ class StaticRepoTest extends PHPUnit_Framework_TestCase $this->assertTrue(StaticRepo::checkParam(0,'BigInteger')); $this->assertFalse(StaticRepo::checkParam(18446744073700000000,'BigInteger')); + $this->assertTrue(StaticRepo::checkParam('19/11/1996','Date')); + $this->assertFalse(StaticRepo::checkParam('15/1551','Date')); + $this->assertFalse(StaticRepo::checkParam('15/1f/5451','Date')); + + $this->assertTrue(StaticRepo::checkParam('19:30','Heure')); + $this->assertFalse(StaticRepo::checkParam('af:65','Heure')); + $this->assertFalse(StaticRepo::checkParam('15451','Heure')); + $this->assertFalse(StaticRepo::checkParam('lololo','lolololo')); } }