Skip to content
Snippets Groups Projects
Commit 937ca9b2 authored by Demian Katz's avatar Demian Katz
Browse files

Fix countability bug.

parent ba476ca2
No related merge requests found
......@@ -41,7 +41,7 @@ namespace VuFindSearch;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org
*/
class ParamBag
class ParamBag implements \Countable
{
/**
* Parameters
......@@ -238,4 +238,14 @@ class ParamBag
}
return $request;
}
/**
* Get a count of parameters set in the bag.
*
* @return int
*/
public function count()
{
return count($this->params);
}
}
......@@ -97,4 +97,19 @@ class ParamBagTest extends TestCase
$bag3->mergeWithAll([$bag1, $bag2]);
$this->assertEquals(['a' => [1], 'b' => [2], 'c' => [3]], $bag3->getArrayCopy());
}
/**
* Test countability.
*
* @return void
*/
public function testCountability()
{
$bag = new ParamBag();
$this->assertEquals(0, count($bag));
$bag->set('foo', 'bar');
$this->assertEquals(1, count($bag));
$bag->set('xyzzy', 'baz');
$this->assertEquals(2, count($bag));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment