Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 29 files changed
  • 0 comments
  • 1 contributor

Showing 29 changed files with 251 additions and 134 deletions. Show diff stats Hide diff stats

  1. +6 6 php/src/Evoke/Model/Factory.php
  2. +3 3 php/src/Evoke/Model/Mapper/DB/DB.php
  3. +5 5 php/src/Evoke/Model/Mapper/DB/Joint.php
  4. +16 16 php/src/Evoke/Model/Mapper/DB/JointAdmin.php
  5. +8 8 php/src/Evoke/Model/Mapper/DB/JointAdminLinked.php
  6. +2 2 php/src/Evoke/Model/Mapper/DB/Table.php
  7. +2 2 php/src/Evoke/Model/Mapper/DB/TableAdminTranslation.php
  8. +2 2 php/src/Evoke/Model/Mapper/DB/Tables.php
  9. +3 3 php/src/Evoke/Model/Mapper/Session/Session.php
  10. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/DBIface.php
  11. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/PDO.php
  12. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/PDOStatement.php
  13. +5 5 php/src/Evoke/{Persistance → Persistence}/DB/SQL.php
  14. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/SQLIface.php
  15. +5 5 php/src/Evoke/{Persistance → Persistence}/DB/Table/Info.php
  16. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/Table/InfoIface.php
  17. +8 8 php/src/Evoke/{Persistance → Persistence}/DB/Table/Joins.php
  18. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/Table/JoinsIface.php
  19. +5 5 php/src/Evoke/{Persistance → Persistence}/DB/Table/ListID.php
  20. +2 2 php/src/Evoke/{Persistance → Persistence}/DB/Table/ListIDIface.php
  21. +1 1  php/src/Evoke/{Persistance → Persistence}/Filesystem.php
  22. +1 1  php/src/Evoke/{Persistance → Persistence}/FilesystemIface.php
  23. +2 2 php/src/Evoke/{Persistance → Persistence}/Session.php
  24. +2 2 php/src/Evoke/{Persistance → Persistence}/SessionIface.php
  25. +4 4 php/src/Evoke/{Persistance → Persistence}/SessionManager.php
  26. +2 2 php/src/Evoke/{Persistance → Persistence}/SessionManagerIface.php
  27. +3 3 php/src/Evoke/Service/Log/File.php
  28. +12 8 php/src/Evoke/Service/Provider.php
  29. +140 27 php/test/unit/Evoke/Service/ProviderTest.php
12 php/src/Evoke/Model/Factory.php
@@ -2,7 +2,7 @@
2 2 namespace Evoke\Model;
3 3
4 4 use DomainException,
5   - Evoke\Persistance\DB\SQLIface,
  5 + Evoke\Persistence\DB\SQLIface,
6 6 Evoke\Service\ProviderIface;
7 7
8 8 /**
@@ -23,7 +23,7 @@ class Factory implements FactoryIface
23 23
24 24 /**
25 25 * SQL Object.
26   - * @var Evoke\Persistance\DB\SQLIface
  26 + * @var Evoke\Persistence\DB\SQLIface
27 27 */
28 28 protected $sql;
29 29
@@ -102,7 +102,7 @@ public function buildData(/* String */ $tableName = '',
102 102 *
103 103 * @param mixed[] Parameters for the table info.
104 104 *
105   - * @return Evoke\Persistance\DB\Table\Info
  105 + * @return Evoke\Persistence\DB\Table\Info
106 106 */
107 107 public function buildInfo(Array $params)
108 108 {
@@ -112,7 +112,7 @@ public function buildInfo(Array $params)
112 112 }
113 113
114 114 return $this->provider->make(
115   - 'Evoke\Persistance\DB\Table\Info', $params);
  115 + 'Evoke\Persistence\DB\Table\Info', $params);
116 116 }
117 117
118 118 /**
@@ -150,7 +150,7 @@ public function buildMapperDBJoint(Array $params)
150 150 if (!empty($params['Joins']) && isset($params['Table_Name']))
151 151 {
152 152 $params['Joins'] = $this->provider->make(
153   - 'Evoke\Persistance\DB\Table\Joins',
  153 + 'Evoke\Persistence\DB\Table\Joins',
154 154 array('Info' => $this->buildInfo(
155 155 array('Table_Name' => $params['Table_Name'])),
156 156 'Joins' => $this->buildJoins(
@@ -254,7 +254,7 @@ protected function buildJoins(Array $joins, $tableName)
254 254 {
255 255 $childTable = $matches[2];
256 256 $builtJoins[] = $this->provider->make(
257   - 'Evoke\Persistance\DB\Table\Joins',
  257 + 'Evoke\Persistence\DB\Table\Joins',
258 258 array('Child_Field' => $matches[3],
259 259 'Info' => $this->buildInfo(
260 260 array('Table_Name' => $childTable)),
6 php/src/Evoke/Model/Mapper/DB/DB.php
@@ -2,7 +2,7 @@
2 2 namespace Evoke\Model\Mapper\DB;
3 3
4 4 use Evoke\Model\Mapper\MapperIface,
5   - Evoke\Persistance\DB\SQLIface;
  5 + Evoke\Persistence\DB\SQLIface;
6 6
7 7 /**
8 8 * DB
@@ -18,14 +18,14 @@
18 18 {
19 19 /**
20 20 * SQL Object
21   - * @var Evoke\Persistance\DB\SQLIface
  21 + * @var Evoke\Persistence\DB\SQLIface
22 22 */
23 23 protected $sql;
24 24
25 25 /**
26 26 * Construct a DB Mapper.
27 27 *
28   - * @param Evoke\Persistance\DB\SQLIface SQL object.
  28 + * @param Evoke\Persistence\DB\SQLIface SQL object.
29 29 */
30 30 public function __construct(SQLIface $sql)
31 31 {
10 php/src/Evoke/Model/Mapper/DB/Joint.php
... ... @@ -1,8 +1,8 @@
1 1 <?php
2 2 namespace Evoke\Model\Mapper\DB;
3 3
4   -use Evoke\Persistance\DB\SQLIface,
5   - Evoke\Persistance\DB\Table\JoinsIface,
  4 +use Evoke\Persistence\DB\SQLIface,
  5 + Evoke\Persistence\DB\Table\JoinsIface,
6 6 InvalidArgumentException;
7 7
8 8 /**
@@ -23,7 +23,7 @@ class Joint extends DB
23 23 * The joins provide the relationships of the data, allowing it to be joint
24 24 * together into a meaningful unit of data.
25 25 *
26   - * @var Evoke\Persistance\DB\Table\JoinsIface
  26 + * @var Evoke\Persistence\DB\Table\JoinsIface
27 27 */
28 28 protected $joins;
29 29
@@ -42,10 +42,10 @@ class Joint extends DB
42 42 /**
43 43 * Construct a Mapper for of a joint set of database tables.
44 44 *
45   - * @param Evoke\Persistance\DB\SQLIface
  45 + * @param Evoke\Persistence\DB\SQLIface
46 46 * SQL object.
47 47 * @param string The table name where joins start from.
48   - * @param Evoke\Persistance\DB\Table\JoinsIface
  48 + * @param Evoke\Persistence\DB\Table\JoinsIface
49 49 * Joins object.
50 50 * @param mixed[] Select statement settings.
51 51 */
32 php/src/Evoke/Model/Mapper/DB/JointAdmin.php
@@ -3,10 +3,10 @@
3 3
4 4 use Evoke\Message\TreeIface,
5 5 Evoke\Model\AdminIface,
6   - Evoke\Persistance\DB\SQLIface,
7   - Evoke\Persistance\DB\Table\JoinsIface,
8   - Evoke\Persistance\DB\Table\ListIDIface,
9   - Evoke\Persistance\SessionManagerIface,
  6 + Evoke\Persistence\DB\SQLIface,
  7 + Evoke\Persistence\DB\Table\JoinsIface,
  8 + Evoke\Persistence\DB\Table\ListIDIface,
  9 + Evoke\Persistence\SessionManagerIface,
10 10 Exception,
11 11 RuntimeException;
12 12
@@ -36,26 +36,26 @@ class JointAdmin extends Joint implements AdminIface
36 36
37 37 /**
38 38 * Session Manager
39   - * @var Evoke\Persistance\SessionManagerIface
  39 + * @var Evoke\Persistence\SessionManagerIface
40 40 */
41 41 protected $sessionManager;
42 42
43 43 /**
44 44 * Database List ID management
45   - * @var Evoke\Persistance\DB\Table\ListIDIface
  45 + * @var Evoke\Persistence\DB\Table\ListIDIface
46 46 */
47 47 protected $tableListID;
48 48
49 49 /**
50 50 * Construct an Administration Model of a joint set of database tables.
51 51 *
52   - * @param Evoke\Persistance\DB\SQLIface
  52 + * @param Evoke\Persistence\DB\SQLIface
53 53 * SQL object.
54 54 * @param string The table name where joins start from.
55   - * @param Evoke\Persistance\DB\Table\JoinsIface
  55 + * @param Evoke\Persistence\DB\Table\JoinsIface
56 56 * Joins object.
57   - * @param Evoke\Persistance\SessionManagerIface SessionManager object.
58   - * @param Evoke\Persistance\DB\Table\ListIDIface
  57 + * @param Evoke\Persistence\SessionManagerIface SessionManager object.
  58 + * @param Evoke\Persistence\DB\Table\ListIDIface
59 59 * DB List ID Table object.
60 60 * @param Evoke\Message\TreeIface
61 61 * Failure messages object.
@@ -449,7 +449,7 @@ protected function addEntries(&$data, $join)
449 449 * Delete the records for the current table.
450 450 *
451 451 * @param mixed[] The records to be deleted.
452   - * @param Evoke\Persistance\DB\Table\JoinsIface The Joins object.
  452 + * @param Evoke\Persistence\DB\Table\JoinsIface The Joins object.
453 453 */
454 454 protected function deleteEntries($data, $join)
455 455 {
@@ -492,7 +492,7 @@ protected function deleteEntries($data, $join)
492 492 * Order is important when callback functions alter the data they receive.
493 493 *
494 494 * @param mixed[] The data to traverse.
495   - * @param Evoke\Persistance\DB\Table\JoinsIface
  495 + * @param Evoke\Persistence\DB\Table\JoinsIface
496 496 * The joins object to traverse the data with.
497 497 * @return mixed[] The data after possibly being modified by the callbacks.
498 498 */
@@ -538,7 +538,7 @@ protected function recurse(Array $callbacks,
538 538 * Feeback the List_ID from the joint child records into the parent record.
539 539 *
540 540 * @param mixed[] The parent record.
541   - * @param Evoke\Persistance\DB\Table\JoinsIface
  541 + * @param Evoke\Persistence\DB\Table\JoinsIface
542 542 * The Join to the child record.
543 543 */
544 544 protected function feedbackListID(&$parentRecord, $join)
@@ -568,7 +568,7 @@ protected function feedbackListID(&$parentRecord, $join)
568 568 * Validate all of the data specified with the Joins.
569 569 *
570 570 * @param mixed[] The data to validate.
571   - * @param Evoke\Persistance\DB\Table\JoinsIface
  571 + * @param Evoke\Persistence\DB\Table\JoinsIface
572 572 * The Joins object to validate the data with.
573 573 * @return bool Whether the data is valid or not.
574 574 */
@@ -586,7 +586,7 @@ protected function validate($data, JoinsIface $joins)
586 586 * Validate the entries for the table.
587 587 *
588 588 * @param mixed[] The data for the table.
589   - * @param Evoke\Persistance\DB\Table\JoinsIface The join for the data.
  589 + * @param Evoke\Persistence\DB\Table\JoinsIface The join for the data.
590 590 */
591 591 protected function validateEntries(Array $data,
592 592 JoinsIface $join)
@@ -625,7 +625,7 @@ protected function validateEntries(Array $data,
625 625 * @param mixed[] The array of callbacks that we are calling from.
626 626 * @param string Index for the callback that we want to call.
627 627 * @param mixed[] The data to pass to the callback by reference.
628   - * @param Evoke\Persistance\DB\Table\JoinsIface
  628 + * @param Evoke\Persistence\DB\Table\JoinsIface
629 629 * The Joins object to pass to the callback.
630 630 */
631 631 private function call(Array $callbacks, $cb, Array &$data, $joins)
16 php/src/Evoke/Model/Mapper/DB/JointAdminLinked.php
@@ -2,10 +2,10 @@
2 2 namespace Evoke\Model\Mapper\DB;
3 3
4 4 use Evoke\Message\TreeIface,
5   - Evoke\Persistance\DB\SQLIface,
6   - Evoke\Persistance\DB\Table\JoinsIface,
7   - Evoke\Persistance\DB\Table\ListIDIface,
8   - Evoke\Persistance\SessionManagerIface;
  5 + Evoke\Persistence\DB\SQLIface,
  6 + Evoke\Persistence\DB\Table\JoinsIface,
  7 + Evoke\Persistence\DB\Table\ListIDIface,
  8 + Evoke\Persistence\SessionManagerIface;
9 9 /**
10 10 * JointAdminLinked
11 11 *
@@ -46,14 +46,14 @@ class JointAdminLinked extends JointAdmin
46 46
47 47 /** Construct an Administration Model of a joint set of database tables with
48 48 * linked information in the filesystem.
49   - * @param Evoke\Persistance\DB\SQLIface
  49 + * @param Evoke\Persistence\DB\SQLIface
50 50 * SQL object.
51 51 * @param string Table name where joins start from.
52   - * @param Evoke\Persistance\DB\Table\JoinsIface
  52 + * @param Evoke\Persistence\DB\Table\JoinsIface
53 53 * Joins object.
54   - * @param Evoke\Persistance\SessionManagerIface
  54 + * @param Evoke\Persistence\SessionManagerIface
55 55 * SessionManager object.
56   - * @param Evoke\Persistance\DB\Table\ListIDIface
  56 + * @param Evoke\Persistence\DB\Table\ListIDIface
57 57 * DB List ID Table object.
58 58 * @param Evoke\Message\TreeIface
59 59 * Failure messages object.
4 php/src/Evoke/Model/Mapper/DB/Table.php
... ... @@ -1,7 +1,7 @@
1 1 <?php
2 2 namespace Evoke\Model\Mapper\DB;
3 3
4   -use Evoke\Persistance\DB\SQLIface,
  4 +use Evoke\Persistence\DB\SQLIface,
5 5 InvalidArgumentException;
6 6
7 7 /**
@@ -30,7 +30,7 @@ class Table extends DB
30 30
31 31 /** Construct a mapper for a database table.
32 32 *
33   - * @param Evoke\Persistance\DB\SQLIface
  33 + * @param Evoke\Persistence\DB\SQLIface
34 34 * SQL object.
35 35 * @param string The database table that the model represents.
36 36 * @param mixed[] Select statement settings.
4 php/src/Evoke/Model/Mapper/DB/TableAdminTranslation.php
... ... @@ -1,8 +1,8 @@
1 1 <?php
2 2 namespace Evoke\Model\Mapper\DB;
3 3
4   -use Evoke\Persistance\DB\SQLIface,
5   - Evoke\Persistance\FilesystemIface,
  4 +use Evoke\Persistence\DB\SQLIface,
  5 + Evoke\Persistence\FilesystemIface,
6 6 Exception,
7 7 InvalidArgumentException;
8 8
4 php/src/Evoke/Model/Mapper/DB/Tables.php
... ... @@ -1,7 +1,7 @@
1 1 <?php
2 2 namespace Evoke\Model\Mapper\DB;
3 3
4   -use Evoke\Persistance\DB\SQLIface;
  4 +use Evoke\Persistence\DB\SQLIface;
5 5
6 6 /**
7 7 * Tables Mapper
@@ -30,7 +30,7 @@ class Tables extends DB
30 30 /**
31 31 * Construct a model for a list of database tables.
32 32 *
33   - * @param Evoke\Persistance\DB\SQLIface
  33 + * @param Evoke\Persistence\DB\SQLIface
34 34 * SQL object.
35 35 * @param mixed[] Extra tables to list.
36 36 * @param mixed[] Tables to ignore for the list.
6 php/src/Evoke/Model/Mapper/Session/Session.php
@@ -2,7 +2,7 @@
2 2 namespace Evoke\Model\Mapper\Session;
3 3
4 4 use Evoke\Model\Mapper\MapperIface,
5   - Evoke\Persistance\SessionManagerIface;
  5 + Evoke\Persistence\SessionManagerIface;
6 6
7 7 /**
8 8 * Session Mapper
@@ -16,14 +16,14 @@ class Session implements MapperIface
16 16 {
17 17 /**
18 18 * Session Manager
19   - * @var Evoke\Persistance\SessionManagerIface
  19 + * @var Evoke\Persistence\SessionManagerIface
20 20 */
21 21 protected $sessionManager;
22 22
23 23 /**
24 24 * Construct a Session Mapper.
25 25 *
26   - * @param Evoke\Persistance\SessionManagerIfaceSessionManager
  26 + * @param Evoke\Persistence\SessionManagerIfaceSessionManager
27 27 * The Session Manager for the part of the session we are mapping.
28 28 */
29 29 public function __construct(SessionManagerIface $sessionManager)
4 php/src/Evoke/Persistance/DB/DBIface.php → php/src/Evoke/Persistence/DB/DBIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB;
  2 +namespace Evoke\Persistence\DB;
3 3
4 4 /**
5 5 * DBIface
@@ -10,7 +10,7 @@
10 10 * @author Paul Young <evoke@youngish.homelinux.org>
11 11 * @copyright Copyright (c) 2012 Paul Young
12 12 * @license MIT
13   - * @package Persistance
  13 + * @package Persistence
14 14 */
15 15 interface DBIface
16 16 {
4 php/src/Evoke/Persistance/DB/PDO.php → php/src/Evoke/Persistence/DB/PDO.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB;
  2 +namespace Evoke\Persistence\DB;
3 3
4 4 use InvalidArgumentException;
5 5
@@ -11,7 +11,7 @@
11 11 * @author Paul Young <evoke@youngish.homelinux.org>
12 12 * @copyright Copyright (c) 2012 Paul Young
13 13 * @license MIT
14   - * @package Persistance
  14 + * @package Persistence
15 15 */
16 16 class PDO extends \PDO implements DBIface
17 17 {
4 php/src/Evoke/Persistance/DB/PDOStatement.php → php/src/Evoke/Persistence/DB/PDOStatement.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB;
  2 +namespace Evoke\Persistence\DB;
3 3
4 4 use Evoke\Message\Exception\DB as ExceptionDB,
5 5 Exception;
@@ -10,7 +10,7 @@
10 10 * @author Paul Young <evoke@youngish.homelinux.org>
11 11 * @copyright Copyright (c) 2012 Paul Young
12 12 * @license MIT
13   - * @package Persistance
  13 + * @package Persistence
14 14 */
15 15 class PDOStatement extends \PDOStatement
16 16 {
10 php/src/Evoke/Persistance/DB/SQL.php → php/src/Evoke/Persistence/DB/SQL.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB;
  2 +namespace Evoke\Persistence\DB;
3 3
4 4 use Evoke\Message\Exception\DB as ExceptionDB,
5 5 Exception;
@@ -24,13 +24,13 @@
24 24 * @author Paul Young <evoke@youngish.homelinux.org>
25 25 * @copyright Copyright (c) 2012 Paul Young
26 26 * @license MIT
27   - * @package Persistance
  27 + * @package Persistence
28 28 */
29 29 class SQL implements SQLIface
30 30 {
31 31 /**
32 32 * Database object.
33   - * @var Evoke\Persistance\DB\DBIface
  33 + * @var Evoke\Persistence\DB\DBIface
34 34 */
35 35 protected $db;
36 36
@@ -49,12 +49,12 @@ class SQL implements SQLIface
49 49 /**
50 50 * Construct an SQL object.
51 51 *
52   - * @param Evoke\Persistance\DB\DBIface
  52 + * @param Evoke\Persistence\DB\DBIface
53 53 * Database object to perform the SQL on.
54 54 */
55 55 public function __construct(
56 56 DBIface $database,
57   - /* String */ $statementClass = 'Evoke\Persistance\DB\PDOStatement')
  57 + /* String */ $statementClass = 'Evoke\Persistence\DB\PDOStatement')
58 58 {
59 59 $this->db = $database;
60 60 $this->statementClass = $statementClass;
4 php/src/Evoke/Persistance/DB/SQLIface.php → php/src/Evoke/Persistence/DB/SQLIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB;
  2 +namespace Evoke\Persistence\DB;
3 3
4 4 /**
5 5 * SQLIface
@@ -7,7 +7,7 @@
7 7 * @author Paul Young <evoke@youngish.homelinux.org>
8 8 * @copyright Copyright (c) 2012 Paul Young
9 9 * @license MIT
10   - * @package Persistance
  10 + * @package Persistence
11 11 */
12 12 interface SQLIface extends DBIface
13 13 {
10 php/src/Evoke/Persistance/DB/Table/Info.php → php/src/Evoke/Persistence/DB/Table/Info.php
... ... @@ -1,8 +1,8 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB\Table;
  2 +namespace Evoke\Persistence\DB\Table;
3 3
4 4 use Evoke\Message\TreeIface,
5   - Evoke\Persistance\DB\SQLIface,
  5 + Evoke\Persistence\DB\SQLIface,
6 6 InvalidArgumentException,
7 7 OutOfRangeException;
8 8
@@ -14,7 +14,7 @@
14 14 * @author Paul Young <evoke@youngish.homelinux.org>
15 15 * @copyright Copyright (c) 2012 Paul Young
16 16 * @license MIT
17   - * @package Persistance
  17 + * @package Persistence
18 18 */
19 19 class Info implements InfoIface
20 20 {
@@ -56,7 +56,7 @@ class Info implements InfoIface
56 56
57 57 /**
58 58 * SQL object.
59   - * @var Evoke\Persistance\DB\SQLIface
  59 + * @var Evoke\Persistence\DB\SQLIface
60 60 */
61 61 protected $sql;
62 62
@@ -69,7 +69,7 @@ class Info implements InfoIface
69 69 /**
70 70 * Construct a Table Info object.
71 71 *
72   - * @param Evoke\Persistance\DB\SQLIface SQL object.
  72 + * @param Evoke\Persistence\DB\SQLIface SQL object.
73 73 * @param string Table Name.
74 74 * @param Evoke\Message\TreeIface Failures.
75 75 */
4 php/src/Evoke/Persistance/DB/Table/InfoIface.php → php/src/Evoke/Persistence/DB/Table/InfoIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB\Table;
  2 +namespace Evoke\Persistence\DB\Table;
3 3
4 4 /**
5 5 * InfoIface
@@ -7,7 +7,7 @@
7 7 * @author Paul Young <evoke@youngish.homelinux.org>
8 8 * @copyright Copyright (c) 2012 Paul Young
9 9 * @license MIT
10   - * @package Persistance
  10 + * @package Persistence
11 11 */
12 12 interface InfoIface extends \Evoke\Service\ValiditionIface
13 13 {
16 php/src/Evoke/Persistance/DB/Table/Joins.php → php/src/Evoke/Persistence/DB/Table/Joins.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB\Table;
  2 +namespace Evoke\Persistence\DB\Table;
3 3
4 4 use InvalidArgumentException;
5 5
@@ -58,7 +58,7 @@
58 58 * @author Paul Young <evoke@youngish.homelinux.org>
59 59 * @copyright Copyright (c) 2012 Paul Young
60 60 * @license MIT
61   - * @package Persistance
  61 + * @package Persistence
62 62 */
63 63 class Joins implements JoinsIface
64 64 {
@@ -96,7 +96,7 @@ class Joins implements JoinsIface
96 96
97 97 /**
98 98 * Database Table Info
99   - * @var Evoke\Persistance\DB\Table\InfoIface
  99 + * @var Evoke\Persistence\DB\Table\InfoIface
100 100 */
101 101 protected $info;
102 102
@@ -109,7 +109,7 @@ class Joins implements JoinsIface
109 109 /**
110 110 * Array ofJoin objects from this node to other Join objects in the join
111 111 * tree.
112   - * @var Evoke\Persistance\DB\Table\JoinsIface[]
  112 + * @var Evoke\Persistence\DB\Table\JoinsIface[]
113 113 */
114 114 protected $joins;
115 115
@@ -149,12 +149,12 @@ class Joins implements JoinsIface
149 149 /**
150 150 * Construct the Joins object.
151 151 *
152   - * @param Evoke\Persistance\DB\Table\InfoIface
  152 + * @param Evoke\Persistence\DB\Table\InfoIface
153 153 * DB Table Info object.
154 154 * @param string Table Name.
155 155 * @param string Parent Field.
156 156 * @param string Child Field.
157   - * @param Evoke\Persistance\DB\Table\JoinsIface[]
  157 + * @param Evoke\Persistence\DB\Table\JoinsIface[]
158 158 * Joins from this node.
159 159 * @param string Admin Managed.
160 160 * @param string Compare Type.
@@ -349,7 +349,7 @@ public function getFailures()
349 349 /**
350 350 * Get the joins.
351 351 *
352   - * @return Evoke\Persistance\DB\Table\JoinsIface[]
  352 + * @return Evoke\Persistence\DB\Table\JoinsIface[]
353 353 */
354 354 public function getJoins()
355 355 {
@@ -528,7 +528,7 @@ protected function getRowID($row)
528 528 /**
529 529 * Build the join from the join components.
530 530 *
531   - * @param Evoke\Persistance\DB\Table\JoinsIface
  531 + * @param Evoke\Persistence\DB\Table\JoinsIface
532 532 *
533 533 * @return string
534 534 */
4 php/src/Evoke/Persistance/DB/Table/JoinsIface.php → php/src/Evoke/Persistence/DB/Table/JoinsIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB\Table;
  2 +namespace Evoke\Persistence\DB\Table;
3 3
4 4 /**
5 5 * JoinsIface
@@ -7,7 +7,7 @@
7 7 * @author Paul Young <evoke@youngish.homelinux.org>
8 8 * @copyright Copyright (c) 2012 Paul Young
9 9 * @license MIT
10   - * @package Persistance
  10 + * @package Persistence
11 11 */
12 12 interface JoinsIface
13 13 {
10 php/src/Evoke/Persistance/DB/Table/ListID.php → php/src/Evoke/Persistence/DB/Table/ListID.php
... ... @@ -1,8 +1,8 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB\Table;
  2 +namespace Evoke\Persistence\DB\Table;
3 3
4 4 use Evoke\Message\Exception\DB as ExceptionDB,
5   - Evoke\Persistance\DB\SQLIface,
  5 + Evoke\Persistence\DB\SQLIface,
6 6 Exception,
7 7 LogicException;
8 8
@@ -12,7 +12,7 @@
12 12 * @author Paul Young <evoke@youngish.homelinux.org>
13 13 * @copyright Copyright (c) 2012 Paul Young
14 14 * @license MIT
15   - * @package Persistance
  15 + * @package Persistence
16 16 */
17 17 class ListID
18 18 {
@@ -30,14 +30,14 @@ class ListID
30 30
31 31 /**
32 32 * SQL object.
33   - * @var Evoke\Persistance\DB\SQLIface
  33 + * @var Evoke\Persistence\DB\SQLIface
34 34 */
35 35 protected $sql;
36 36
37 37 /**
38 38 * Construct a List ID object.
39 39 *
40   - * @param Evoke\Persistance\DB\SQLIface
  40 + * @param Evoke\Persistence\DB\SQLIface
41 41 * SQL object.
42 42 * @param string[] Fields used in the List ID table.
43 43 * @param string The table name of the List ID table.
4 php/src/Evoke/Persistance/DB/Table/ListIDIface.php → php/src/Evoke/Persistence/DB/Table/ListIDIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance\DB\Table;
  2 +namespace Evoke\Persistence\DB\Table;
3 3
4 4 /**
5 5 * ListIDIface
@@ -7,7 +7,7 @@
7 7 * @author Paul Young <evoke@youngish.homelinux.org>
8 8 * @copyright Copyright (c) 2012 Paul Young
9 9 * @license MIT
10   - * @package Persistance
  10 + * @package Persistence
11 11 */
12 12 interface ListIDIface
13 13 {
2  php/src/Evoke/Persistance/Filesystem.php → php/src/Evoke/Persistence/Filesystem.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance;
  2 +namespace Evoke\Persistence;
3 3
4 4 use FilesystemIterator,
5 5 RecursiveDirectoryIterator,
2  php/src/Evoke/Persistance/FilesystemIface.php → php/src/Evoke/Persistence/FilesystemIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance;
  2 +namespace Evoke\Persistence;
3 3
4 4 interface FilesystemIface
5 5 {
4 php/src/Evoke/Persistance/Session.php → php/src/Evoke/Persistence/Session.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance;
  2 +namespace Evoke\Persistence;
3 3
4 4 use RuntimeException;
5 5
@@ -9,7 +9,7 @@
9 9 * @author Paul Young <evoke@youngish.homelinux.org>
10 10 * @copyright Copyright (c) 2012 Paul Young
11 11 * @license MIT
12   - * @package Persistance
  12 + * @package Persistence
13 13 */
14 14 class Session implements SessionIface
15 15 {
4 php/src/Evoke/Persistance/SessionIface.php → php/src/Evoke/Persistence/SessionIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance;
  2 +namespace Evoke\Persistence;
3 3
4 4 /**
5 5 * SessionIface
@@ -7,7 +7,7 @@
7 7 * @author Paul Young <evoke@youngish.homelinux.org>
8 8 * @copyright Copyright (c) 2012 Paul Young
9 9 * @license MIT
10   - * @package Persistance
  10 + * @package Persistence
11 11 */
12 12 interface SessionIface
13 13 {
8 php/src/Evoke/Persistance/SessionManager.php → php/src/Evoke/Persistence/SessionManager.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance;
  2 +namespace Evoke\Persistence;
3 3
4 4 /**
5 5 * SessionManager
@@ -9,7 +9,7 @@
9 9 * @author Paul Young <evoke@youngish.homelinux.org>
10 10 * @copyright Copyright (c) 2012 Paul Young
11 11 * @license MIT
12   - * @package Persistance
  12 + * @package Persistence
13 13 */
14 14 class SessionManager implements SessionManagerIface
15 15 {
@@ -25,14 +25,14 @@ class SessionManager implements SessionManagerIface
25 25
26 26 /**
27 27 * Session object.
28   - * @var Evoke\Persistance\SessionIface
  28 + * @var Evoke\Persistence\SessionIface
29 29 */
30 30 protected $session;
31 31
32 32 /**
33 33 * Construct a Session Manager object.
34 34 *
35   - * @param Evoke\Persistance\SessionIface Session
  35 + * @param Evoke\Persistence\SessionIface Session
36 36 * @param string[] Domain to manage.
37 37 */
38 38 public function __construct(SessionIface $session,
4 php/src/Evoke/Persistance/SessionManagerIface.php → php/src/Evoke/Persistence/SessionManagerIface.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2   -namespace Evoke\Persistance;
  2 +namespace Evoke\Persistence;
3 3
4 4 /**
5 5 * SessionManagerIface
@@ -7,7 +7,7 @@
7 7 * @author Paul Young <evoke@youngish.homelinux.org>
8 8 * @copyright Copyright (c) 2012 Paul Young
9 9 * @license MIT
10   - * @package Persistance
  10 + * @package Persistence
11 11 */
12 12 interface SessionManagerIface
13 13 {
6 php/src/Evoke/Service/Log/File.php
@@ -2,7 +2,7 @@
2 2 namespace Evoke\Service\Log;
3 3
4 4 use DateTime,
5   - Evoke\Persistance\FilesystemIface,
  5 + Evoke\Persistence\FilesystemIface,
6 6 InvalidArgumentException;
7 7
8 8 /**
@@ -47,7 +47,7 @@ class File implements LoggerIface
47 47
48 48 /**
49 49 * Filesystem
50   - * @var Evoke\Persistance\FilesystemIface
  50 + * @var Evoke\Persistence\FilesystemIface
51 51 */
52 52 protected $filesystem;
53 53
@@ -66,7 +66,7 @@ class File implements LoggerIface
66 66 /**
67 67 * Construct a File Logger object.
68 68 *
69   - * @param Evoke\Persistance\FilesystemIface
  69 + * @param Evoke\Persistence\FilesystemIface
70 70 * Filesystem object
71 71 * @param bool Whether to append to the file.
72 72 * @param int(octal) The directory mode for the log file.
20 php/src/Evoke/Service/Provider.php
@@ -153,11 +153,19 @@ protected function getDependency(ReflectionParameter $reflectionParam,
153 153 return $passedParameters[$reflectionParam->name];
154 154 }
155 155
  156 + /* As far as I can tell the difference between isDefaultValueAvailable
  157 + * and isOptional is that:
  158 + * isDefaultValueAvailable is for classes in PHP
  159 + * isOptional is for builtin objects from the PHP engine
  160 + */
156 161 if ($reflectionParam->isDefaultValueAvailable())
157 162 {
158   - // Use a default value.
159 163 return $reflectionParam->getDefaultValue();
160 164 }
  165 + elseif ($reflectionParam->isOptional())
  166 + {
  167 + return null;
  168 + }
161 169
162 170 $depClass = $reflectionParam->getClass();
163 171
@@ -165,7 +173,7 @@ protected function getDependency(ReflectionParameter $reflectionParam,
165 173 {
166 174 $message = 'Missing ';
167 175 $message .= $reflectionParam->isArray() ? 'Array' : 'Scalar';
168   - $message .= ' dependency.';
  176 + $message .= ' Dependency';
169 177
170 178 // It must be an unset Scalar or Array. Bail hard and early.
171 179 throw new InvalidArgumentException($message);
@@ -177,12 +185,8 @@ protected function getDependency(ReflectionParameter $reflectionParam,
177 185 return $this->make($depClass->name);
178 186 }
179 187
180   - if ($reflectionParam->isOptional())
181   - {
182   - return null;
183   - }
184   -
185   - throw new InvalidArgumentException('Missing Interface Dependency');
  188 + throw new InvalidArgumentException(
  189 + 'Missing Abstract/Interface Dependency');
186 190 }
187 191
188 192 /**
167 php/test/unit/Evoke/Service/ProviderTest.php
@@ -5,33 +5,6 @@
5 5 Evoke\Service\Provider,
6 6 PHPUnit_Framework_TestCase;
7 7
8   -// Interface for the test.
9   -interface PI
10   -{
11   -
12   -}
13   -
14   -// Classes for the test.
15   -class PA
16   -{
17   - // No constructor means no dependencies.
18   -}
19   -
20   -class PB
21   -{
22   - public function __construct(PI $paramOne, Array $arr) {}
23   -}
24   -
25   -class PC implements PI
26   -{
27   - public function __construct($int, $strDefault = 'Paul') {}
28   -}
29   -
30   -class PD
31   -{
32   - public function __construct(PA $concrete, PI $interface) {}
33   -}
34   -
35 8 /**
36 9 * Provider Test.
37 10 */
@@ -64,6 +37,113 @@ public function testMake($object, $classname, $params)
64 37 $this->assertInstanceOf($classname, $object->make($classname, $params));
65 38 }
66 39
  40 + /**
  41 + * Trying to make an object with a missing Abstract/Interface throws IAE.
  42 + *
  43 + * @covers Evoke\Service\Provider::getDependency
  44 + * @depends Evoke_Test\Service\ProviderTest::test__construct
  45 + * @expectedException InvalidArgumentException
  46 + * @expectedExceptionMessage Missing Abstract/Interface Dependency
  47 + */
  48 + public function testMissingDependencyAbstractInterface()
  49 + {
  50 + $object = new Provider($this->getMock('Evoke\Service\CacheIface'));
  51 + $object->make('Evoke_Test\Service\PD');
  52 + }
  53 +
  54 + /**
  55 + * Trying to make an object with a missing Array throws IAE.
  56 + *
  57 + * @covers Evoke\Service\Provider::getDependency
  58 + * @depends Evoke_Test\Service\ProviderTest::test__construct
  59 + * @expectedException InvalidArgumentException
  60 + * @expectedExceptionMessage Missing Array Dependency
  61 + */
  62 + public function testMissingDependencyArray()
  63 + {
  64 + $object = new Provider($this->getMock('Evoke\Service\CacheIface'));
  65 + $object->make('Evoke_Test\Service\PB',
  66 + array('Param_One' => $this->getMock(
  67 + 'Evoke_Test\Service\PC', NULL, array(1))));
  68 + }
  69 +
  70 + /**
  71 + * Trying to make an object with a missing scalar throws IAE.
  72 + *
  73 + * @covers Evoke\Service\Provider::getDependency
  74 + * @depends Evoke_Test\Service\ProviderTest::test__construct
  75 + * @expectedException InvalidArgumentException
  76 + * @expectedExceptionMessage Missing Scalar Dependency
  77 + */
  78 + public function testMissingDependencyScalar()
  79 + {
  80 + $object = new Provider($this->getMock('Evoke\Service\CacheIface'));
  81 + $object->make('Evoke_Test\Service\PC');
  82 + }
  83 +
  84 + /**
  85 + * Test that the reflection cache is set when it is fresh.
  86 + *
  87 + * @covers Evoke\Service\Provider::getReflection
  88 + * @depends Evoke_Test\Service\ProviderTest::test__construct
  89 + */
  90 + public function testReflectionCacheFresh()
  91 + {
  92 + $cache = $this->getMock('Evoke\Service\CacheIface');
  93 +
  94 + $i = 0;
  95 + $cache->expects($this->at($i++))
  96 + ->method('exists')
  97 + ->with($this->equalTo('Evoke_Test\Service\PD'))
  98 + ->will($this->returnValue(false));
  99 +
  100 + $cache->expects($this->at($i++))
  101 + ->method('set')
  102 + ->with($this->equalTo('Evoke_Test\Service\PD'),
  103 + $this->arrayHasKey('Class'));
  104 +
  105 +
  106 + $object = new Provider($cache);
  107 + $object->make('Evoke_Test\Service\PD',
  108 + array('Interface' => $this->getMock(
  109 + 'Evoke_Test\Service\PC', NULL, array(1))));
  110 + }
  111 +
  112 + /**
  113 + * Test that the reflection cache is used when it has information.
  114 + *
  115 + * @covers Evoke\Service\Provider::getReflection
  116 + * @depends Evoke_Test\Service\ProviderTest::test__construct
  117 + */
  118 + public function testReflectionCacheUsed()
  119 + {
  120 + // Now simulate the cache being used.
  121 + $usedCache = $this->getMock('Evoke\Service\CacheIface');
  122 +
  123 + $i = 0;
  124 + $usedCache->expects($this->at($i++))
  125 + ->method('exists')
  126 + ->with($this->equalTo('Evoke_Test\Service\PD'))
  127 + ->will($this->returnValue(true));
  128 +
  129 + $pdClass = new \ReflectionClass('Evoke_Test\Service\PD');
  130 + $pdParams = $pdClass->getConstructor()->getParameters();
  131 +
  132 + $usedCache->expects($this->at($i++))
  133 + ->method('get')
  134 + ->with($this->equalTo('Evoke_Test\Service\PD'))
  135 + ->will($this->returnValue(
  136 + array('Class' => $pdClass,
  137 + 'Params' => $pdParams)));
  138 +
  139 + $object = new Provider($usedCache);
  140 + $this->assertInstanceOf(
  141 + 'Evoke_Test\Service\PD',
  142 + $object->make('Evoke_Test\Service\PD',
  143 + array('Interface' => $this->getMock(
  144 + 'Evoke_Test\Service\PC', NULL, array(1)))));
  145 + }
  146 +
67 147 /******************/
68 148 /* Data Providers */
69 149 /******************/
@@ -99,9 +179,42 @@ public function providerMake()
99 179 'Classname' => 'Evoke_Test\Service\PD',
100 180 'Params' => array('Interface' => $this->getMock(
101 181 'Evoke_Test\Service\PC', NULL, array(1))));
  182 +
  183 + $tests['Built_In_Class'] = array(
  184 + 'Object' => new Provider($this->getMock('Evoke\Service\Cache')),
  185 + 'Classname' => 'DateTime',
  186 + 'Params' => array());
102 187
103 188 return $tests;
104 189 }
105 190 }
106 191
  192 +// Interface for the test.
  193 +interface PI
  194 +{
  195 +
  196 +}
  197 +
  198 +// Classes for the test.
  199 +class PA
  200 +{
  201 + // No constructor means no dependencies.
  202 +}
  203 +
  204 +class PB
  205 +{
  206 + public function __construct(PI $paramOne, Array $arr) {}
  207 +}
  208 +
  209 +class PC implements PI
  210 +{
  211 + public function __construct($int, $strDefault = 'Paul') {}
  212 +}
  213 +
  214 +class PD
  215 +{
  216 + public function __construct(PA $concrete, PI $interface) {}
  217 +}
  218 +
  219 +
107 220 // EOF

No commit comments for this range

Something went wrong with that request. Please try again.