Skip to content

Commit

Permalink
Implement Countable interface in OptionsPropertyGroup
Browse files Browse the repository at this point in the history
This is really needed in OptionsPropertyRootGroup, but makes sense here
as well.

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Aug 1, 2017
1 parent b188c18 commit 76e0e6d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libraries/properties/options/OptionsPropertyGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @todo modify descriptions if needed, when the options are integrated
* @package PhpMyAdmin
*/
abstract class OptionsPropertyGroup extends OptionsPropertyItem
abstract class OptionsPropertyGroup extends OptionsPropertyItem implements \Countable
{
/**
* Holds a group of properties (PMA\libraries\properties\options\OptionsPropertyItem instances)
Expand Down Expand Up @@ -87,6 +87,18 @@ public function getProperties()
*/
public function getNrOfProperties()
{
if (is_null($this->_properties)) {
return 0;
}
return count($this->_properties);
}

/**
* Countable interface implementation.
*
* @return int
*/
public function count() {
return $this->getNrOfProperties();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,17 @@ public function testGetItemType()
);
}

/**
* Test for contable interface
*
* @return void
*/
public function testCountable()
{
$this->assertEquals(
0,
count($this->object)
);
}

}

0 comments on commit 76e0e6d

Please sign in to comment.