diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html index 6e0bff6..2de59f5 100755 --- a/coverage/StaticRepo.php.html +++ b/coverage/StaticRepo.php.html @@ -60,13 +60,13 @@
2 / 4
CRAP
-
- 84.62% covered (warning) +
+ 84.91% covered (warning)
-
84.62%
-
44 / 52
+
84.91%
+
45 / 53
@@ -87,15 +87,15 @@
50.00%
2 / 4
- 48.42 + 49.36
-
- 84.62% covered (warning) +
+ 84.91% covered (warning)
-
84.62%
-
44 / 52
+
84.91%
+
45 / 53
@@ -171,15 +171,15 @@
0.00%
0 / 1
- 33.17 + 34.05
-
- 81.25% covered (warning) +
+ 81.82% covered (warning)
-
81.25%
-
26 / 32
+
81.82%
+
27 / 33
@@ -298,62 +298,64 @@
109
        =============================================================*/
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; -
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; -
123
-
124
            // [2] Chaine de caractère (longueur variable) -
125
            case 'String': -
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; -
132
-
133
            case 'SmallInteger': -
134
                $checker = $checker && is_int($variable) && $variable<pow(2,16); -
135
                break; -
136
-
137
            case 'TinyInteger': -
138
                $checker = $checker && is_int($variable) && $variable<pow(2,8); -
139
                break; -
140
-
141
            case 'BigInteger': -
142
                $checker = $checker && is_int($variable) && $variable<pow(2,64); -
143
                break; -
144
-
145
            case 'Date': -
146
                $checker = $checker && is_string($variable) && preg_match('/(\d+)\/(\d+)\/(\d+)/is',$variable); -
147
                break; -
148
-
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
        /* [3] On retourne le résultat de la vérif -
159
        =============================================================*/ -
160
        return $checker; -
161
-
162
    } +
112
        $len = 8; +
113
+
114
        //si on a un type scalairexlongueur, on traite +
115
        if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){ +
116
            $dbtype = $matches[1][0]; +
117
            $len    = $matches[2][0]; +
118
        } +
119
+
120
        switch($dbtype){ +
121
            // [1] 'M' / 'F'  +
122
            case 'Civilite': +
123
                $checker = $checker && is_string($variable) && in_array($variable, ['M','F']); +
124
                break; +
125
+
126
            // [2] Chaine de caractère (longueur variable) +
127
            case 'String': +
128
                $checker = $checker && is_string($variable) && strlen($variable) <= $len; +
129
                break; +
130
+
131
            case 'Integer': +
132
                $checker = $checker && is_int($variable) && $variable<pow(2, 32); +
133
                break; +
134
+
135
            case 'SmallInteger': +
136
                $checker = $checker && is_int($variable) && $variable<pow(2, 16); +
137
                break; +
138
+
139
            case 'TinyInteger': +
140
                $checker = $checker && is_int($variable) && $variable<pow(2, 8); +
141
                break; +
142
+
143
            case 'BigInteger': +
144
                $checker = $checker && is_int($variable) && $variable<pow(2, 64); +
145
                break; +
146
+
147
            case 'Date': +
148
                $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) || preg_match('/\d{4}\/\d{2}\/\d{2}/', $variable) ); +
149
                break; +
150
+
151
            case 'Heure': +
152
                $checker = $checker && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable); +
153
                break; +
154
+
155
            // [N] Type inconnu +
156
            default: $checker = false; break; +
157
        } +
158
+
159
+
160
        /* [3] On retourne le résultat de la vérif +
161
        =============================================================*/ +
162
        return $checker;
163
-
164
-
165
} +
164
    } +
165
166
-
167
?> +
167
} +
168
+
169
?> @@ -366,7 +368,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/coverage/dashboard.html b/coverage/dashboard.html index 7d2b492..cfccc41 100755 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -59,6 +59,7 @@ StaticRepo84% + RDVRepo85% @@ -75,7 +76,8 @@ - StaticRepo48 + StaticRepo49 + RDVRepo25 @@ -113,6 +115,7 @@ + getByMonth0% checkParam81% delNumeric85% getAll86% @@ -133,8 +136,9 @@ - checkParam33 + checkParam34 delNumeric10 + getByMonth6 getAll5 add5 @@ -146,7 +150,7 @@
@@ -167,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); @@ -185,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,4,4,18], "Method Coverage")) + .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,4,4,18], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -235,7 +239,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[84.615384615385,42,"StaticRepo<\/a>"],[96.428571428571,15,"MedecinRepo<\/a>"],[96.875,39,"PatientRepo<\/a>"],[94,22,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[84.905660377358,43,"StaticRepo<\/a>"],[96.428571428571,15,"MedecinRepo<\/a>"],[97.435897435897,44,"PatientRepo<\/a>"],[85.454545454545,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -259,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>"],[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>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"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.818181818182,29,"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>"],[96.774193548387,17,"PatientRepo::add<\/a>"],[96.774193548387,16,"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>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[0,2,"RDVRepo::getByMonth<\/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 ee047e3..3879f91 100755 --- a/coverage/index.html +++ b/coverage/index.html @@ -43,21 +43,21 @@ Total
-
- 92.73% covered (success) +
+ 91.25% covered (success)
-
92.73%
-
204 / 220
+
91.25%
+
219 / 240
-
- 69.23% covered (warning) +
+ 66.67% covered (warning)
-
69.23%
-
18 / 26
+
66.67%
+
18 / 27
0.00% covered (danger) @@ -71,21 +71,21 @@ repos
-
- 95.24% covered (success) +
+ 93.05% covered (success)
-
95.24%
-
160 / 168
+
93.05%
+
174 / 187
-
- 72.73% covered (warning) +
+ 69.57% covered (warning)
-
72.73%
-
16 / 22
+
69.57%
+
16 / 23
0.00% covered (danger) @@ -99,13 +99,13 @@ StaticRepo.php
-
- 84.62% covered (warning) +
+ 84.91% covered (warning)
-
84.62%
-
44 / 52
+
84.91%
+
45 / 53
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.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/coverage/repos/MedecinRepo.php.html b/coverage/repos/MedecinRepo.php.html index 52e2944..890edd0 100755 --- a/coverage/repos/MedecinRepo.php.html +++ b/coverage/repos/MedecinRepo.php.html @@ -318,7 +318,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/coverage/repos/PatientRepo.php.html b/coverage/repos/PatientRepo.php.html index 1f46bbc..f3d84a8 100755 --- a/coverage/repos/PatientRepo.php.html +++ b/coverage/repos/PatientRepo.php.html @@ -61,13 +61,13 @@
5 / 7
CRAP
-
- 96.88% covered (success) +
+ 97.44% covered (success)
-
96.88%
-
62 / 64
+
97.44%
+
76 / 78
@@ -88,15 +88,15 @@
71.43%
5 / 7
- 39 + 44
-
- 96.88% covered (success) +
+ 97.44% covered (success)
-
96.88%
-
62 / 64
+
97.44%
+
76 / 78
@@ -130,19 +130,19 @@
0.00%
0 / 1
- 14 + 17
-
- 95.65% covered (success) +
+ 96.77% covered (success)
-
95.65%
-
22 / 23
+
96.77%
+
30 / 31
-  update +  update
0.00% covered (danger) @@ -151,19 +151,19 @@
0.00%
0 / 1
- 14 + 16
-
- 96.00% covered (success) +
+ 96.77% covered (success)
-
96.00%
-
24 / 25
+
96.77%
+
30 / 31
-  delete +  delete
100.00% covered (success) @@ -184,7 +184,7 @@ -  updateMedecinTraitant +  updateMedecinTraitant
100.00% covered (success) @@ -205,7 +205,7 @@ -  search +  search
100.00% covered (success) @@ -226,7 +226,7 @@ -  getAll +  getAll
100.00% covered (success) @@ -272,107 +272,134 @@     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); - -         $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 delete($idPatient){ +         $correctTypes = StaticRepo::checkParam($civilite,'Civilite'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($prenom,'String45'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($nom,'String45'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($adresse,'String255'); +         $correctTypes = $correctTypes && ( $adresse2 == 'null' || $adresse2 === null || StaticRepo::checkParam($adresse2, 'String255') ); +         $correctTypes = $correctTypes && StaticRepo::checkParam($ville,'String50'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50'); +         $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') ); +         if( !$correctTypes ) 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'      => (strlen($adresse2)>0) ? $adresse2 : NULL, +             '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){ + +         $correctTypes = StaticRepo::checkParam($civilite,'Civilite'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($prenom,'String45'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($nom,'String45'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($adresse,'String255'); +         $correctTypes = $correctTypes && ( $adresse2 == 'null' || $adresse2 === null || StaticRepo::checkParam($adresse2, 'String255') ); +         $correctTypes = $correctTypes && StaticRepo::checkParam($ville,'String50'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date'); +         $correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50'); +         $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') ); +         if( !$correctTypes ) 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]); - -     } - -     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() ); +         $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]); +         //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')){ 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]); + +     } + +     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() ); + +     } + + } @@ -385,7 +412,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/coverage/repos/RDVRepo.php.html b/coverage/repos/RDVRepo.php.html index 843a591..920d128 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) +
+ 62.50% covered (warning)
-
71.43%
-
5 / 7
+
62.50%
+
5 / 8
CRAP -
-
- 94.00% covered (success) +
+
+ 85.45% covered (warning)
-
94.00%
-
47 / 50
+
85.45%
+
47 / 55
@@ -81,22 +81,22 @@
0.00%
0 / 1
-
- 71.43% covered (warning) +
+ 62.50% covered (warning)
-
71.43%
-
5 / 7
- 22.10 -
-
- 94.00% covered (success) +
62.50%
+
5 / 8
+ 25.77 +
+
+ 85.45% covered (warning)
-
94.00%
-
47 / 50
+
85.45%
+
47 / 55
@@ -246,6 +246,27 @@
13 / 15
+ +  getByMonth +
+
+ 0.00% covered (danger) +
+
+ +
0.00%
+
0 / 1
+ 6 +
+
+ 0.00% covered (danger) +
+
+ +
0.00%
+
0 / 5
+ + @@ -352,7 +373,17 @@         return StaticRepo::delNumeric($req->fetchAll());     } - } +     public static function getByMonth($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]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + + } @@ -365,7 +396,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html index deeea19..19cafd2 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.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html index 983e68e..ac78bbe 100755 --- a/coverage/repos/dashboard.html +++ b/coverage/repos/dashboard.html @@ -59,6 +59,7 @@ + RDVRepo85% @@ -75,6 +76,7 @@ + RDVRepo25 @@ -112,6 +114,7 @@ + getByMonth0% getAll86% add88% @@ -130,6 +133,7 @@ + getByMonth6 getAll5 add5 @@ -141,7 +145,7 @@
@@ -162,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); @@ -180,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,2,4,16], "Method Coverage")) + .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,2,4,16], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -230,7 +234,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[96.428571428571,15,"MedecinRepo<\/a>"],[96.875,39,"PatientRepo<\/a>"],[94,22,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[96.428571428571,15,"MedecinRepo<\/a>"],[97.435897435897,44,"PatientRepo<\/a>"],[85.454545454545,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -254,7 +258,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .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>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"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>"],[96.774193548387,17,"PatientRepo::add<\/a>"],[96.774193548387,16,"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>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[0,2,"RDVRepo::getByMonth<\/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 50723c4..801e50a 100755 --- a/coverage/repos/index.html +++ b/coverage/repos/index.html @@ -44,21 +44,21 @@ Total
-
- 95.24% covered (success) +
+ 93.05% covered (success)
-
95.24%
-
160 / 168
+
93.05%
+
174 / 187
-
- 72.73% covered (warning) +
+ 69.57% covered (warning)
-
72.73%
-
16 / 22
+
69.57%
+
16 / 23
0.00% covered (danger) @@ -100,13 +100,13 @@ PatientRepo.php
-
- 96.88% covered (success) +
+ 97.44% covered (success)
-
96.88%
-
62 / 64
+
97.44%
+
76 / 78
71.43% covered (warning) @@ -126,23 +126,23 @@ - RDVRepo.php -
-
- 94.00% covered (success) -
-
- -
94.00%
-
47 / 50
+ RDVRepo.php
-
- 71.43% covered (warning) +
+ 85.45% covered (warning)
-
71.43%
-
5 / 7
+
85.45%
+
47 / 55
+
+
+ 62.50% covered (warning) +
+
+ +
62.50%
+
5 / 8
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.3 at Tue Dec 15 8:23:37 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015.

diff --git a/managers/RDV.class.php b/managers/RDV.class.php index 37e247c..33024ab 100755 --- a/managers/RDV.class.php +++ b/managers/RDV.class.php @@ -119,4 +119,8 @@ class RDV } } + public function getSVG($params){ + + } + } \ No newline at end of file diff --git a/repositories/StaticRepo.php b/repositories/StaticRepo.php index 26c4eee..34c68b4 100755 --- a/repositories/StaticRepo.php +++ b/repositories/StaticRepo.php @@ -145,7 +145,7 @@ class StaticRepo{ break; case 'Date': - $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) ); + $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) || preg_match('/\d{4}\/\d{2}\/\d{2}/', $variable) ); break; case 'Heure': diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index bec3383..193684c 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -18,17 +18,17 @@ class PatientRepo } public static function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ + $correctTypes = StaticRepo::checkParam($civilite,'Civilite'); $correctTypes = $correctTypes && StaticRepo::checkParam($prenom,'String45'); - $correctTypes = $correctTypes && StaticRepo::checkParam($prenom,'String45'); $correctTypes = $correctTypes && StaticRepo::checkParam($nom,'String45'); $correctTypes = $correctTypes && StaticRepo::checkParam($adresse,'String255'); - $correctTypes = $correctTypes && ( $adresse2 == 'null' || StaticRepo::checkParam($adresse2, 'String255') ); + $correctTypes = $correctTypes && ( $adresse2 == 'null' || $adresse2 === null || StaticRepo::checkParam($adresse2, 'String255') ); $correctTypes = $correctTypes && StaticRepo::checkParam($ville,'String50'); $correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String'); $correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date'); $correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50'); - $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || StaticRepo::checkParam($medecinTraitant, 'Integer') ); + $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') ); if( !$correctTypes ) return false; $dateNaissance = strtotime($dateNaissance); @@ -73,12 +73,17 @@ class PatientRepo 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;} + $correctTypes = StaticRepo::checkParam($civilite,'Civilite'); + $correctTypes = $correctTypes && StaticRepo::checkParam($prenom,'String45'); + $correctTypes = $correctTypes && StaticRepo::checkParam($nom,'String45'); + $correctTypes = $correctTypes && StaticRepo::checkParam($adresse,'String255'); + $correctTypes = $correctTypes && ( $adresse2 == 'null' || $adresse2 === null || StaticRepo::checkParam($adresse2, 'String255') ); + $correctTypes = $correctTypes && StaticRepo::checkParam($ville,'String50'); + $correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String'); + $correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date'); + $correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50'); + $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') ); + if( !$correctTypes ) return false; $dateNaissance = strtotime($dateNaissance); $dateNaissance = Date('o-m-d',$dateNaissance); diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php index a61bae6..8b26025 100755 --- a/repositories/repos/RDVRepo.php +++ b/repositories/repos/RDVRepo.php @@ -99,4 +99,14 @@ class RDVRepo return StaticRepo::delNumeric($req->fetchAll()); } + public static function getByMonth($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]); + return StaticRepo::delNumeric($req->fetchAll()); + } + }