Skip to content

Commit

Permalink
Added count method
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegall committed Feb 6, 2023
1 parent 7e1faf8 commit 33afba3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ContainsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,14 @@ public function clear(array $except = []): void

$container = $persist->container();
}

/**
* Get the count of the container
*
* @return int
*/
public function count(): int
{
return count($this->container());
}
}
5 changes: 5 additions & 0 deletions tests/ContainsDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,9 @@ public function test_when_remove_but_key_does_not_exist_then_nothing_happens()
$this->assertFalse($this->subject->has('missing.property'));
}

public function test_when_count_then_correct_count()
{
$this->assertEquals(3, $this->subject->count());
}

}

0 comments on commit 33afba3

Please sign in to comment.