diff --git a/.gitignore b/.gitignore
index 83405db..1904248 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/test.php
/.idea
/.project
/repositories/config.json
diff --git a/Docs/RDVExemple.json b/Docs/RDVExemple.json
new file mode 100644
index 0000000..a9f083e
--- /dev/null
+++ b/Docs/RDVExemple.json
@@ -0,0 +1,602 @@
+[
+ {
+ "DateRDV": "2015-06-08 11:33:43",
+ "Duree": 60,
+ "Patient_Id": 14,
+ "Medecin_Id": 60
+ },
+ {
+ "DateRDV": "2015-04-04 04:22:43",
+ "Duree": 60,
+ "Patient_Id": 9,
+ "Medecin_Id": 15
+ },
+ {
+ "DateRDV": "2015-02-08 06:05:29",
+ "Duree": 60,
+ "Patient_Id": 63,
+ "Medecin_Id": 2
+ },
+ {
+ "DateRDV": "2015-04-13 08:48:17",
+ "Duree": 30,
+ "Patient_Id": 3,
+ "Medecin_Id": 40
+ },
+ {
+ "DateRDV": "2015-10-23 08:01:11",
+ "Duree": 60,
+ "Patient_Id": 58,
+ "Medecin_Id": 74
+ },
+ {
+ "DateRDV": "2015-01-02 09:51:57",
+ "Duree": 30,
+ "Patient_Id": 33,
+ "Medecin_Id": 71
+ },
+ {
+ "DateRDV": "2015-09-17 11:06:44",
+ "Duree": 60,
+ "Patient_Id": 21,
+ "Medecin_Id": 69
+ },
+ {
+ "DateRDV": "2015-07-08 03:55:22",
+ "Duree": 30,
+ "Patient_Id": 18,
+ "Medecin_Id": 41
+ },
+ {
+ "DateRDV": "2015-10-18 03:25:50",
+ "Duree": 60,
+ "Patient_Id": 23,
+ "Medecin_Id": 70
+ },
+ {
+ "DateRDV": "2015-01-29 09:21:39",
+ "Duree": 30,
+ "Patient_Id": 82,
+ "Medecin_Id": 8
+ },
+ {
+ "DateRDV": "2015-08-23 02:57:06",
+ "Duree": 30,
+ "Patient_Id": 13,
+ "Medecin_Id": 25
+ },
+ {
+ "DateRDV": "2015-11-30 05:11:44",
+ "Duree": 60,
+ "Patient_Id": 20,
+ "Medecin_Id": 77
+ },
+ {
+ "DateRDV": "2015-06-28 09:08:39",
+ "Duree": 30,
+ "Patient_Id": 49,
+ "Medecin_Id": 82
+ },
+ {
+ "DateRDV": "2015-06-08 02:00:35",
+ "Duree": 30,
+ "Patient_Id": 93,
+ "Medecin_Id": 13
+ },
+ {
+ "DateRDV": "2015-03-01 02:39:30",
+ "Duree": 60,
+ "Patient_Id": 28,
+ "Medecin_Id": 26
+ },
+ {
+ "DateRDV": "2015-09-24 01:02:24",
+ "Duree": 30,
+ "Patient_Id": 56,
+ "Medecin_Id": 76
+ },
+ {
+ "DateRDV": "2015-09-06 11:13:48",
+ "Duree": 60,
+ "Patient_Id": 39,
+ "Medecin_Id": 97
+ },
+ {
+ "DateRDV": "2015-01-15 03:36:46",
+ "Duree": 30,
+ "Patient_Id": 46,
+ "Medecin_Id": 78
+ },
+ {
+ "DateRDV": "2015-06-26 09:04:07",
+ "Duree": 60,
+ "Patient_Id": 97,
+ "Medecin_Id": 55
+ },
+ {
+ "DateRDV": "2015-07-01 08:27:26",
+ "Duree": 60,
+ "Patient_Id": 22,
+ "Medecin_Id": 50
+ },
+ {
+ "DateRDV": "2015-02-08 11:50:46",
+ "Duree": 30,
+ "Patient_Id": 18,
+ "Medecin_Id": 34
+ },
+ {
+ "DateRDV": "2015-01-29 03:27:30",
+ "Duree": 60,
+ "Patient_Id": 14,
+ "Medecin_Id": 58
+ },
+ {
+ "DateRDV": "2015-03-16 01:57:19",
+ "Duree": 30,
+ "Patient_Id": 52,
+ "Medecin_Id": 4
+ },
+ {
+ "DateRDV": "2015-09-21 05:49:59",
+ "Duree": 30,
+ "Patient_Id": 11,
+ "Medecin_Id": 14
+ },
+ {
+ "DateRDV": "2015-08-09 03:58:24",
+ "Duree": 30,
+ "Patient_Id": 91,
+ "Medecin_Id": 29
+ },
+ {
+ "DateRDV": "2015-02-04 06:35:51",
+ "Duree": 30,
+ "Patient_Id": 29,
+ "Medecin_Id": 62
+ },
+ {
+ "DateRDV": "2015-11-04 09:18:35",
+ "Duree": 30,
+ "Patient_Id": 99,
+ "Medecin_Id": 87
+ },
+ {
+ "DateRDV": "2015-05-02 04:25:22",
+ "Duree": 30,
+ "Patient_Id": 2,
+ "Medecin_Id": 50
+ },
+ {
+ "DateRDV": "2015-11-29 02:33:10",
+ "Duree": 60,
+ "Patient_Id": 51,
+ "Medecin_Id": 89
+ },
+ {
+ "DateRDV": "2015-10-15 07:02:24",
+ "Duree": 60,
+ "Patient_Id": 10,
+ "Medecin_Id": 8
+ },
+ {
+ "DateRDV": "2015-04-23 08:57:53",
+ "Duree": 30,
+ "Patient_Id": 65,
+ "Medecin_Id": 35
+ },
+ {
+ "DateRDV": "2015-02-22 04:17:11",
+ "Duree": 60,
+ "Patient_Id": 35,
+ "Medecin_Id": 82
+ },
+ {
+ "DateRDV": "2015-04-04 07:48:57",
+ "Duree": 30,
+ "Patient_Id": 76,
+ "Medecin_Id": 53
+ },
+ {
+ "DateRDV": "2015-09-18 07:48:07",
+ "Duree": 30,
+ "Patient_Id": 94,
+ "Medecin_Id": 19
+ },
+ {
+ "DateRDV": "2015-02-15 07:25:06",
+ "Duree": 60,
+ "Patient_Id": 69,
+ "Medecin_Id": 44
+ },
+ {
+ "DateRDV": "2015-06-08 04:25:39",
+ "Duree": 60,
+ "Patient_Id": 15,
+ "Medecin_Id": 88
+ },
+ {
+ "DateRDV": "2015-11-24 01:33:30",
+ "Duree": 60,
+ "Patient_Id": 84,
+ "Medecin_Id": 20
+ },
+ {
+ "DateRDV": "2015-07-11 04:17:24",
+ "Duree": 60,
+ "Patient_Id": 30,
+ "Medecin_Id": 78
+ },
+ {
+ "DateRDV": "2015-08-12 10:59:53",
+ "Duree": 30,
+ "Patient_Id": 61,
+ "Medecin_Id": 95
+ },
+ {
+ "DateRDV": "2015-09-19 05:08:41",
+ "Duree": 30,
+ "Patient_Id": 11,
+ "Medecin_Id": 23
+ },
+ {
+ "DateRDV": "2015-09-29 07:56:16",
+ "Duree": 30,
+ "Patient_Id": 75,
+ "Medecin_Id": 86
+ },
+ {
+ "DateRDV": "2015-03-22 01:07:22",
+ "Duree": 30,
+ "Patient_Id": 83,
+ "Medecin_Id": 23
+ },
+ {
+ "DateRDV": "2015-06-11 06:05:41",
+ "Duree": 60,
+ "Patient_Id": 89,
+ "Medecin_Id": 20
+ },
+ {
+ "DateRDV": "2015-03-17 04:28:43",
+ "Duree": 60,
+ "Patient_Id": 77,
+ "Medecin_Id": 88
+ },
+ {
+ "DateRDV": "2015-11-27 06:14:03",
+ "Duree": 60,
+ "Patient_Id": 27,
+ "Medecin_Id": 54
+ },
+ {
+ "DateRDV": "2015-03-07 09:38:22",
+ "Duree": 60,
+ "Patient_Id": 2,
+ "Medecin_Id": 4
+ },
+ {
+ "DateRDV": "2015-02-02 01:45:32",
+ "Duree": 30,
+ "Patient_Id": 36,
+ "Medecin_Id": 60
+ },
+ {
+ "DateRDV": "2015-06-18 04:52:09",
+ "Duree": 60,
+ "Patient_Id": 69,
+ "Medecin_Id": 99
+ },
+ {
+ "DateRDV": "2015-06-24 11:53:34",
+ "Duree": 60,
+ "Patient_Id": 89,
+ "Medecin_Id": 40
+ },
+ {
+ "DateRDV": "2015-10-21 04:19:14",
+ "Duree": 60,
+ "Patient_Id": 85,
+ "Medecin_Id": 76
+ },
+ {
+ "DateRDV": "2015-04-14 09:14:08",
+ "Duree": 30,
+ "Patient_Id": 73,
+ "Medecin_Id": 48
+ },
+ {
+ "DateRDV": "2015-04-18 09:11:32",
+ "Duree": 30,
+ "Patient_Id": 90,
+ "Medecin_Id": 11
+ },
+ {
+ "DateRDV": "2015-08-23 02:03:16",
+ "Duree": 30,
+ "Patient_Id": 17,
+ "Medecin_Id": 57
+ },
+ {
+ "DateRDV": "2015-05-03 02:25:11",
+ "Duree": 30,
+ "Patient_Id": 21,
+ "Medecin_Id": 63
+ },
+ {
+ "DateRDV": "2015-08-07 09:12:44",
+ "Duree": 30,
+ "Patient_Id": 97,
+ "Medecin_Id": 92
+ },
+ {
+ "DateRDV": "2015-05-09 06:18:46",
+ "Duree": 30,
+ "Patient_Id": 21,
+ "Medecin_Id": 32
+ },
+ {
+ "DateRDV": "2015-09-10 10:26:08",
+ "Duree": 30,
+ "Patient_Id": 9,
+ "Medecin_Id": 6
+ },
+ {
+ "DateRDV": "2015-09-06 11:38:09",
+ "Duree": 30,
+ "Patient_Id": 26,
+ "Medecin_Id": 48
+ },
+ {
+ "DateRDV": "2015-07-22 04:18:29",
+ "Duree": 60,
+ "Patient_Id": 81,
+ "Medecin_Id": 90
+ },
+ {
+ "DateRDV": "2015-11-29 12:25:38",
+ "Duree": 60,
+ "Patient_Id": 91,
+ "Medecin_Id": 2
+ },
+ {
+ "DateRDV": "2015-07-22 05:27:02",
+ "Duree": 60,
+ "Patient_Id": 92,
+ "Medecin_Id": 27
+ },
+ {
+ "DateRDV": "2015-02-12 09:02:35",
+ "Duree": 30,
+ "Patient_Id": 50,
+ "Medecin_Id": 35
+ },
+ {
+ "DateRDV": "2015-11-07 04:16:19",
+ "Duree": 60,
+ "Patient_Id": 98,
+ "Medecin_Id": 35
+ },
+ {
+ "DateRDV": "2015-11-20 09:12:30",
+ "Duree": 60,
+ "Patient_Id": 22,
+ "Medecin_Id": 57
+ },
+ {
+ "DateRDV": "2015-11-13 09:09:55",
+ "Duree": 30,
+ "Patient_Id": 98,
+ "Medecin_Id": 69
+ },
+ {
+ "DateRDV": "2015-08-04 07:56:59",
+ "Duree": 30,
+ "Patient_Id": 88,
+ "Medecin_Id": 44
+ },
+ {
+ "DateRDV": "2015-07-15 07:32:15",
+ "Duree": 60,
+ "Patient_Id": 72,
+ "Medecin_Id": 59
+ },
+ {
+ "DateRDV": "2015-05-26 07:16:43",
+ "Duree": 60,
+ "Patient_Id": 22,
+ "Medecin_Id": 57
+ },
+ {
+ "DateRDV": "2015-03-08 05:21:56",
+ "Duree": 60,
+ "Patient_Id": 95,
+ "Medecin_Id": 19
+ },
+ {
+ "DateRDV": "2015-01-12 02:11:24",
+ "Duree": 30,
+ "Patient_Id": 51,
+ "Medecin_Id": 72
+ },
+ {
+ "DateRDV": "2015-11-29 08:22:29",
+ "Duree": 60,
+ "Patient_Id": 95,
+ "Medecin_Id": 56
+ },
+ {
+ "DateRDV": "2015-10-09 06:50:11",
+ "Duree": 60,
+ "Patient_Id": 53,
+ "Medecin_Id": 5
+ },
+ {
+ "DateRDV": "2015-01-09 04:59:41",
+ "Duree": 60,
+ "Patient_Id": 9,
+ "Medecin_Id": 44
+ },
+ {
+ "DateRDV": "2015-03-06 01:45:26",
+ "Duree": 30,
+ "Patient_Id": 50,
+ "Medecin_Id": 90
+ },
+ {
+ "DateRDV": "2015-08-20 07:20:01",
+ "Duree": 30,
+ "Patient_Id": 70,
+ "Medecin_Id": 60
+ },
+ {
+ "DateRDV": "2015-08-08 03:18:32",
+ "Duree": 60,
+ "Patient_Id": 34,
+ "Medecin_Id": 23
+ },
+ {
+ "DateRDV": "2015-07-07 05:49:03",
+ "Duree": 30,
+ "Patient_Id": 100,
+ "Medecin_Id": 97
+ },
+ {
+ "DateRDV": "2015-05-14 12:17:01",
+ "Duree": 60,
+ "Patient_Id": 37,
+ "Medecin_Id": 4
+ },
+ {
+ "DateRDV": "2015-05-26 02:31:26",
+ "Duree": 30,
+ "Patient_Id": 26,
+ "Medecin_Id": 92
+ },
+ {
+ "DateRDV": "2015-07-10 01:06:31",
+ "Duree": 30,
+ "Patient_Id": 37,
+ "Medecin_Id": 19
+ },
+ {
+ "DateRDV": "2015-02-12 06:48:08",
+ "Duree": 60,
+ "Patient_Id": 26,
+ "Medecin_Id": 36
+ },
+ {
+ "DateRDV": "2015-04-04 09:58:14",
+ "Duree": 60,
+ "Patient_Id": 56,
+ "Medecin_Id": 51
+ },
+ {
+ "DateRDV": "2015-09-09 11:00:38",
+ "Duree": 30,
+ "Patient_Id": 58,
+ "Medecin_Id": 60
+ },
+ {
+ "DateRDV": "2015-04-07 06:46:08",
+ "Duree": 60,
+ "Patient_Id": 6,
+ "Medecin_Id": 18
+ },
+ {
+ "DateRDV": "2015-12-07 04:20:04",
+ "Duree": 60,
+ "Patient_Id": 64,
+ "Medecin_Id": 6
+ },
+ {
+ "DateRDV": "2015-09-28 02:43:55",
+ "Duree": 60,
+ "Patient_Id": 57,
+ "Medecin_Id": 66
+ },
+ {
+ "DateRDV": "2015-08-26 12:20:03",
+ "Duree": 60,
+ "Patient_Id": 27,
+ "Medecin_Id": 36
+ },
+ {
+ "DateRDV": "2015-09-06 08:31:43",
+ "Duree": 30,
+ "Patient_Id": 71,
+ "Medecin_Id": 80
+ },
+ {
+ "DateRDV": "2015-04-21 08:18:20",
+ "Duree": 30,
+ "Patient_Id": 22,
+ "Medecin_Id": 30
+ },
+ {
+ "DateRDV": "2015-08-13 11:00:42",
+ "Duree": 30,
+ "Patient_Id": 10,
+ "Medecin_Id": 72
+ },
+ {
+ "DateRDV": "2015-05-18 01:40:59",
+ "Duree": 60,
+ "Patient_Id": 2,
+ "Medecin_Id": 78
+ },
+ {
+ "DateRDV": "2015-11-15 05:32:12",
+ "Duree": 60,
+ "Patient_Id": 94,
+ "Medecin_Id": 77
+ },
+ {
+ "DateRDV": "2015-02-27 03:23:52",
+ "Duree": 60,
+ "Patient_Id": 2,
+ "Medecin_Id": 71
+ },
+ {
+ "DateRDV": "2015-11-07 04:56:09",
+ "Duree": 30,
+ "Patient_Id": 96,
+ "Medecin_Id": 52
+ },
+ {
+ "DateRDV": "2015-07-20 10:32:31",
+ "Duree": 30,
+ "Patient_Id": 57,
+ "Medecin_Id": 38
+ },
+ {
+ "DateRDV": "2015-04-09 06:30:20",
+ "Duree": 30,
+ "Patient_Id": 91,
+ "Medecin_Id": 67
+ },
+ {
+ "DateRDV": "2015-10-20 04:25:11",
+ "Duree": 30,
+ "Patient_Id": 56,
+ "Medecin_Id": 98
+ },
+ {
+ "DateRDV": "2015-11-11 08:29:45",
+ "Duree": 30,
+ "Patient_Id": 88,
+ "Medecin_Id": 39
+ },
+ {
+ "DateRDV": "2015-10-21 07:55:43",
+ "Duree": 30,
+ "Patient_Id": 97,
+ "Medecin_Id": 6
+ },
+ {
+ "DateRDV": "2015-07-11 11:02:43",
+ "Duree": 60,
+ "Patient_Id": 7,
+ "Medecin_Id": 22
+ }
+]
\ No newline at end of file
diff --git a/Docs/generateRDV b/Docs/generateRDV
new file mode 100644
index 0000000..ab1fc4b
--- /dev/null
+++ b/Docs/generateRDV
@@ -0,0 +1,9 @@
+[
+ '{{repeat(100)}}',
+ {
+ DateRDV: '{{date(new Date(2015, 0, 1), new Date(), "YYYY-MM-dd hh:mm:ss")}}',
+ Duree: '{{random(30,60)}}',
+ Patient_Id: '{{integer(1,100)}}',
+ Medecin_Id: '{{integer(1,100)}}'
+ }
+]
\ No newline at end of file
diff --git a/coverage/MedecinRepo.php.html b/coverage/MedecinRepo.php.html
index b484acc..efb0d03 100644
--- a/coverage/MedecinRepo.php.html
+++ b/coverage/MedecinRepo.php.html
@@ -51,22 +51,22 @@
0.00%
0 / 1
-
-
80.00% covered (warning)
+
+ 83.33% covered (warning)
- 80.00%
- 4 / 5
+ 83.33%
+ 5 / 6
CRAP
-
-
94.74% covered (success)
+
+ 95.24% covered (success)
- 94.74%
- 18 / 19
+ 95.24%
+ 20 / 21
@@ -80,22 +80,22 @@
0.00%
0 / 1
-
-
80.00% covered (warning)
+
+ 83.33% covered (warning)
- 80.00%
- 4 / 5
- 6.01
+ 83.33%
+ 5 / 6
+ 7
-
-
94.74% covered (success)
+
+ 95.24% covered (success)
- 94.74%
- 18 / 19
+ 95.24%
+ 20 / 21
@@ -203,6 +203,27 @@
4 / 4
+
+ getAll
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 1 / 1
+ 1
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 2 / 2
+
+
@@ -258,7 +279,15 @@
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 ( ) ) ;
+
+ }
+
+ }
@@ -271,7 +300,7 @@
Dead Code
- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015.
+ Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.
diff --git a/coverage/PatientRepo.php.html b/coverage/PatientRepo.php.html
index d6cb59d..dce7f11 100644
--- a/coverage/PatientRepo.php.html
+++ b/coverage/PatientRepo.php.html
@@ -60,13 +60,13 @@
5 / 6
CRAP
-
-
96.67% covered (success)
+
+ 96.43% covered (success)
- 96.67%
- 29 / 30
+ 96.43%
+ 27 / 28
@@ -89,34 +89,13 @@
5 / 6
7
-
-
96.67% covered (success)
+
+ 96.43% covered (success)
- 96.67%
- 29 / 30
-
-
-
- __construct
-
-
- 100.00% covered (success)
-
-
-
- 100.00%
- 1 / 1
- 1
-
-
- 100.00% covered (success)
-
-
-
- 100.00%
- 2 / 2
+ 96.43%
+ 27 / 28
@@ -200,11 +179,11 @@
100.00%
- 3 / 3
+ 2 / 2
- search
+ search
100.00% covered (success)
@@ -221,7 +200,28 @@
100.00%
- 4 / 4
+ 3 / 3
+
+
+
+ getAll
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 1 / 1
+ 1
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 2 / 2
@@ -239,25 +239,25 @@
class PatientRepo
{
- private $connexion ;
+
- public function __construct ( ) {
- $this -> connexion = StaticRepo :: getConnexion ( ) ;
- }
+
+
+
- public function getById ( $id ) {
- $req = $this -> connexion -> prepare ( 'SELECT * FROM Patient WHERE Id = :id' ) ;
+ public static function getById ( $id ) {
+ $req = StaticRepo :: getConnexion ( ) -> prepare ( 'SELECT * FROM Patient WHERE Id = :id' ) ;
$req -> execute ( [ 'id' => $id ] ) ;
return StaticRepo :: delNumeric ( $req -> fetch ( ) , true ) ;
}
- public function add ( $civilite , $prenom , $nom , $adresse , $adresse2 , $ville , $codePostal , $dateNaissance , $lieuNaissance , $numSecu , $medecinTraitant = null ) {
+ 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 = $this -> connexion -> prepare ( 'INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)' ) ;
+ $req = StaticRepo :: getConnexion ( ) -> prepare ( 'INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)' ) ;
$result = $req -> execute ( [ 'civilite' => $civilite ,
'nom' => $nom ,
'prenom' => $prenom ,
@@ -269,37 +269,42 @@
'lieuNaissance' => $lieuNaissance ,
'numSecu' => $numSecu ,
'medecin' => $medecinTraitant ] ) ;
- if ( $result != false ) { return $this -> connexion -> lastInsertId ( ) ; }
+ if ( $result ) { return StaticRepo :: getConnexion ( ) -> lastInsertId ( ) ; }
else { return false ; }
}
- public function delete ( $idPatient ) {
+ public static function delete ( $idPatient ) {
- $req = $this -> connexion -> prepare ( 'DELETE FROM Patient WHERE Id = :id' ) ;
+ $req = StaticRepo :: getConnexion ( ) -> prepare ( 'DELETE FROM Patient WHERE Patient.Id = :id' ) ;
return $req -> execute ( [ 'id' => $idPatient ] ) ;
}
- public function updateMedecinTraitant ( $idPatient , $idMedecin ) {
+ public static function updateMedecinTraitant ( $idPatient , $idMedecin ) {
- $req = $this -> connexion -> prepare ( 'UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id' ) ;
- return $req -> execute ( [ 'medecin' => $idMedecin ,
- 'id' => $idPatient ] ) ;
-
- }
-
- public function search ( $nom , $prenom ) {
-
- $req = $this -> connexion -> prepare ( 'SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom' ) ;
- $req -> execute ( [ 'nom' => $nom ,
- 'prenom' => $prenom ] ) ;
-
- return StaticRepo :: delNumeric ( $req -> fetchAll ( ) ) ;
-
- }
-
- }
+ $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 ) {
+
+ $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 ( ) ) ;
+
+ }
+
+ }
@@ -312,7 +317,7 @@
Dead Code
- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015.
+ Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.
diff --git a/coverage/RDVRepo.php.html b/coverage/RDVRepo.php.html
index d80914d..af5d142 100644
--- a/coverage/RDVRepo.php.html
+++ b/coverage/RDVRepo.php.html
@@ -50,23 +50,23 @@
0.00%
0 / 1
-
-
-
33.33% covered (danger)
+
+
+ 83.33% covered (warning)
-
33.33%
-
2 / 6
-
CRAP
-
-
-
46.43% covered (danger)
+
83.33%
+
5 / 6
+
CRAP
+
+
+ 96.30% covered (success)
-
46.43%
-
13 / 28
+
96.30%
+
26 / 27
@@ -79,23 +79,23 @@
0.00%
0 / 1
-
-
-
33.33% covered (danger)
+
+
+ 83.33% covered (warning)
-
33.33%
-
2 / 6
-
14.53
-
-
-
46.43% covered (danger)
+
83.33%
+
5 / 6
+
7
+
+
+ 96.30% covered (success)
-
46.43%
-
13 / 28
+
96.30%
+
26 / 27
@@ -120,28 +120,28 @@
- getByDate
-
-
-
0.00% covered (danger)
+
getByDate
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
2
-
-
-
0.00% covered (danger)
+
100.00%
+
1 / 1
+
1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 5
+
100.00%
+
4 / 4
- delete
+ delete
100.00% covered (success)
@@ -162,7 +162,7 @@
- add
+ add
0.00% covered (danger)
@@ -183,45 +183,45 @@
- updateDateTime
-
-
-
0.00% covered (danger)
+
updateDateTime
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
2
-
-
-
0.00% covered (danger)
+
100.00%
+
1 / 1
+
1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 4
+
100.00%
+
4 / 4
- getByPatientAndDate
-
-
-
0.00% covered (danger)
+
getByPatientAndDate
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
2
-
-
-
0.00% covered (danger)
+
100.00%
+
1 / 1
+
1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 5
+
100.00%
+
5 / 5
@@ -241,54 +241,53 @@
{
public static function getById ( $id ) {
-
$req = StaticRepo :: getConnexion ( ) -> prepare ( 'SELECT * FROM RDV WHERE Id = :id' ) ;
-
$req -> execute ( [ 'id' => $id ] ) ;
-
return StaticRepo :: delNumeric ( $req -> fetch ( ) , true ) ;
+
$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 = strtotime ( $date ) ;
-
$date = date ( 'o-m-d' , $date ) ;
-
$req = StaticRepo :: getConnexion ( ) -> prepare ( 'SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(DateRDV)) = :date' ) ;
-
$req -> execute ( [ 'date' => $date ] ) ;
-
return StaticRepo :: delNumeric ( $req -> fetchAll ( ) ) ;
-
}
-
-
public static function delete ( $idRDV ) {
-
$req = StaticRepo :: getConnexion ( ) -> prepare ( 'DELETE FROM RDV WHERE 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 ] ) ;
-
-
if ( $result != false ) { return StaticRepo :: getConnexion ( ) -> lastInsertId ( ) ; }
-
else { return false ; }
-
}
-
-
public static function updateDateTime ( $idRDV , $dateTime ) {
-
$date = 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 = strtotime ( $date ) ;
-
$req = StaticRepo :: getConnexion ( ) -> prepare ( 'SELECT * FROM RDV WHERE Patient_Id=:patient AND DateRDV=:date' ) ;
-
$req -> execute ( [ 'patient' => $idPatient ,
-
'date' => $date ] ) ;
-
return StaticRepo :: delNumeric ( $req -> fetchAll ( ) ) ;
-
}
-
-
}
+
$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 ) {
+
$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 ] ) ;
+
+
if ( $result != false ) { return StaticRepo :: getConnexion ( ) -> lastInsertId ( ) ; }
+
else { 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 ( ) ) ;
+
}
+
+
}
@@ -301,7 +300,7 @@
Dead Code
- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015.
+ Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.
diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html
new file mode 100644
index 0000000..ff505c7
--- /dev/null
+++ b/coverage/StaticRepo.php.html
@@ -0,0 +1,397 @@
+
+
+
+
+
Code Coverage for /home/seekdasky/git/projetphp/repositories/StaticRepo.php
+
+
+
+
+
+
+
+
+
+
+
+
+ Code Coverage
+
+
+
+ Classes and Traits
+ Functions and Methods
+ Lines
+
+
+
+
+ Total
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 1
+
+
+ 40.00% covered (danger)
+
+
+
+ 40.00%
+ 2 / 5
+ CRAP
+
+
+ 58.06% covered (warning)
+
+
+
+ 58.06%
+ 18 / 31
+
+
+
+ StaticRepo
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 1
+
+
+ 40.00% covered (danger)
+
+
+
+ 40.00%
+ 2 / 5
+ 62.01
+
+
+ 58.06% covered (warning)
+
+
+
+ 58.06%
+ 18 / 31
+
+
+
+ __construct
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 1
+ 2
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 1
+
+
+
+ getConnexion
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 1 / 1
+ 3
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 5 / 5
+
+
+
+ testConnexion
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 1 / 1
+ 1
+
+
+ 100.00% covered (success)
+
+
+
+ 100.00%
+ 1 / 1
+
+
+
+ delNumeric
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 1
+ 10.29
+
+
+ 85.71% covered (warning)
+
+
+
+ 85.71%
+ 12 / 14
+
+
+
+ checkParam
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 1
+ 72
+
+
+ 0.00% covered (danger)
+
+
+
+ 0.00%
+ 0 / 10
+
+
+
+
+
+
+
+ <?php
+
+ class StaticRepo {
+
+
+ private static $connexion ;
+
+
+ private static $config ;
+
+ private function __construct ( ) {
+
+ }
+
+
+
+
+ public static function getConnexion ( ) {
+ if ( static :: $config == null ) {
+ static :: $config = json_decode ( file_get_contents ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'config.json' ) , true ) ;
+ }
+ if ( static :: $connexion == null ) {
+ static :: $connexion = new PDO ( 'mysql:host=' . static :: $config [ 'host' ] . ';dbname=' . static :: $config [ 'database' ] , static :: $config [ 'login' ] , static :: $config [ 'password' ] ) ;
+ }
+ return static :: $connexion ;
+ }
+
+
+
+
+ public static function testConnexion ( ) {
+ return static :: getConnexion ( ) instanceof PDO ;
+ }
+
+
+
+
+
+
+
+
+
+
+
+ public static function delNumeric ( $fetchData , $oneDimension = false ) {
+
+
+ if ( $fetchData === false ) return false ;
+
+
+
+ if ( ! $oneDimension ) {
+
+
+ for ( $i = 0 ; $i < count ( $fetchData ) ; $i ++ )
+ foreach ( $fetchData [ $i ] as $col => $val ) {
+
+ if ( ! mb_detect_encoding ( $val , 'UTF-8' ) )
+ $fetchData [ $i ] [ $col ] = utf8_encode ( $val ) ;
+
+ if ( is_int ( $col ) )
+ unset ( $fetchData [ $i ] [ $col ] ) ;
+ }
+
+
+
+ } else {
+
+
+ foreach ( $fetchData as $i => $val ) {
+
+ if ( ! mb_detect_encoding ( $val , 'UTF-8' ) )
+ $fetchData [ $i ] = utf8_encode ( $val ) ;
+
+ if ( is_int ( $i ) )
+ unset ( $fetchData [ $i ] ) ;
+ }
+
+ }
+
+ return $fetchData ;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ public static function checkParam ( $variable , $dbtype ) {
+
+
+ if ( ! is_string ( $dbtype ) ) return false ;
+
+
+
+
+ $checker = true ;
+
+ switch ( $dbtype ) {
+
+ case 'Civilité' :
+ $checker = $checker && is_string ( $variable ) && in_array ( array ( 'M' , 'F' ) , $variable ) ;
+ break ;
+
+
+ case 'Nom' :
+ $checker = $checker && is_string ( $variable ) && in_array ( array ( 'M' , 'F' ) , $variable ) ;
+ break ;
+
+
+
+ default : $checker = false ; break ;
+ }
+
+
+
+
+ return $checker ;
+
+ }
+
+
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/coverage/StatsRepo.php.html b/coverage/StatsRepo.php.html
index 0946151..1545de1 100644
--- a/coverage/StatsRepo.php.html
+++ b/coverage/StatsRepo.php.html
@@ -57,7 +57,7 @@
0.00%
-
0 / 2
+
0 / 1
CRAP
0.00%
-
0 / 3
+
0 / 30
@@ -86,8 +86,8 @@
0.00%
- 0 / 2
- 6
+ 0 / 1
+ 72
0.00% covered (danger)
@@ -95,11 +95,11 @@
0.00%
- 0 / 3
+ 0 / 30
- __construct
+ getStats
0.00% covered (danger)
@@ -108,7 +108,7 @@
0.00%
0 / 1
- 2
+ 72
0.00% covered (danger)
@@ -116,28 +116,7 @@
0.00%
- 0 / 2
-
-
-
- getStats
-
-
- 0.00% covered (danger)
-
-
-
- 0.00%
- 0 / 1
- 2
-
-
- 0.00% covered (danger)
-
-
-
- 0.00%
- 0 / 1
+ 0 / 30
@@ -155,18 +134,45 @@
class StatsRepo
{
-
private $connexion ;
-
-
public function __construct ( ) {
-
$this -> connexion = StaticRepo :: getConnexion ( ) ;
-
}
-
-
public function getStats ( ) {
-
-
}
-
-
-
}
+
+
public static function getStats ( ) {
+
$patients = PatientRepo :: getAll ( ) ;
+
+
$homme = [ '25-' => 0 , '25-50' => 0 , '50+' => 0 ] ;
+
$femme = [ '25-' => 0 , '25-50' => 0 , '50+' => 0 ] ;
+
+
foreach ( $patients as $key => $patient ) {
+
$dateNaissance = strtotime ( $patient [ 'DateNaissance' ] ) ;
+
$age = date ( 'Y' , time ( ) - $dateNaissance ) ;
+
$patient [ 'age' ] = $age - 1970 ;
+
+
switch ( $patient [ 'Civilite' ] ) {
+
case 'M' :
+
if ( $patient [ 'age' ] < 25 ) {
+
$homme [ '25-' ] ++ ;
+
} elseif ( $patient [ 'age' ] < 50 ) {
+
$homme [ '25-50' ] ++ ;
+
} else {
+
$homme [ '50+' ] ++ ;
+
}
+
break ;
+
case 'F' :
+
if ( $patient [ 'age' ] < 25 ) {
+
$femme [ '25-' ] ++ ;
+
} elseif ( $patient [ 'age' ] < 50 ) {
+
$femme [ '25-50' ] ++ ;
+
} else {
+
$femme [ '50+' ] ++ ;
+
}
+
break ;
+
}
+
}
+
+
return [ 'H' => $homme , 'F' => $femme ] ;
+
}
+
+
+
}
@@ -179,7 +185,7 @@
Dead Code
- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015.
+ Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.
diff --git a/coverage/dashboard.html b/coverage/dashboard.html
index 29d38dd..734991a 100644
--- a/coverage/dashboard.html
+++ b/coverage/dashboard.html
@@ -2,7 +2,7 @@
-
Dashboard for /home/seekdasky/git/projetphp/repositories/repos
+
Dashboard for /home/seekdasky/git/projetphp/repositories
@@ -18,7 +18,7 @@