Skip to content

Commit

Permalink
clean up static function calls, remove extra code
Browse files Browse the repository at this point in the history
- RecordList doesn't need constructor: removed from class and interface
- static functions need to be declared explicitly in object\Factory
- DOMDocument::loadXML is apparently no longer accessible statically:
  fix RecordList and Record test cases to reflect
- minor documentation fixes
  • Loading branch information
unix1 committed Apr 21, 2013
1 parent f7a4e76 commit a9904c1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 28 deletions.
7 changes: 0 additions & 7 deletions lib360/db/data/IRecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@
interface IRecordList
{

/**
* Constructor.
* @param array $data optional array of IRecord database record objects
* @see IRecord
*/
public function __construct(array $data = array());

/**
* Transforms object into XML representation.
* @return DOMDocument XML document object
Expand Down
18 changes: 2 additions & 16 deletions lib360/db/data/RecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,13 @@
/**
* A record list class.
* This class extends PHP ArrayObject and represents a list of data records.
* @see IDBDataRecordList
* @see DBDataRecord
* @see IRecordList
* @see Record
*/

class RecordList extends \ArrayObject implements IRecordList
{

/**
* Constructor.
* @param array $data optional array of IRecord database record objects
* @see IRecord
* @see Record
*/
public function __construct(array $data = array())
{
foreach ($data as $key => $value)
{
$this->offsetSet($key, $value);
}
}

/**
* Transforms object into XML representation.
* @return DOMDocument XML document object
Expand Down
6 changes: 3 additions & 3 deletions lib360/db/object/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function get($type, $name)
* @param string $base namespace or similar prefix of object type
* @param string $interface interface the object must implement
*/
public function setType($name, $base, $interface)
public static function setType($name, $base, $interface)
{
self::$types[$name] = array('base' => $base, 'interface' => $interface);
}
Expand All @@ -110,7 +110,7 @@ public function setType($name, $base, $interface)
* @return array configuration
* @throw \InvalidArgumentException when $type is not defined
*/
public function getType($type)
public static function getType($type)
{
if (!isset(self::$types[$type]))
{
Expand All @@ -122,7 +122,7 @@ public function getType($type)
/**
* Empties cache
*/
public function flushCache()
public static function flushCache()
{
self::$objects = array();
}
Expand Down
3 changes: 2 additions & 1 deletion lib360/tests/db/data/RecordListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function testToXML()
$r->test2 = 'test 2 value';
$l = new \lib360\db\data\RecordList(array($r));
$expectedXMLString = '<recordlist type="RecordList"><record type="test"><test1>test 1 value</test1><test2>test 2 value</test2></record></recordlist>';
$expectedXML = \DOMDocument::loadXML($expectedXMLString);
$expectedXML = new \DomDocument();
$expectedXML->loadXML($expectedXMLString);
$resultXML = $l->toXML();
$this->assertEqualXMLStructure($expectedXML->firstChild, $resultXML->firstChild, TRUE, "Failed to return correct XML structure");
}
Expand Down
3 changes: 2 additions & 1 deletion lib360/tests/db/data/RecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public function testToXML()
{
$o = new \lib360\db\data\Record('test');
$expectedXMLString = '<record type="test"><test1>test 1 value</test1><test2>test 2 value</test2></record>';
$expectedXML = \DOMDocument::loadXML($expectedXMLString);
$expectedXML = new \DOMDocument();
$expectedXML->loadXML($expectedXMLString);
$o->test1 = 'test 1 value';
$o->test2 = 'test 2 value';
$resultXML = $o->toXML();
Expand Down

0 comments on commit a9904c1

Please sign in to comment.