Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msabramo/php_counter
PHP port of Python's collections.Counter class
https://github.com/msabramo/php_counter
Last synced: 28 days ago
JSON representation
PHP port of Python's collections.Counter class
- Host: GitHub
- URL: https://github.com/msabramo/php_counter
- Owner: msabramo
- Created: 2012-02-28T17:23:00.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-04-26T05:48:35.000Z (over 12 years ago)
- Last Synced: 2024-05-09T20:41:28.108Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# PHP_Counter
## Summary
A PHP port of Python's [collections.Counter class](http://docs.python.org/library/collections.html#counter-objects).
## Author
[Marc Abramowitz](http://marc-abramowitz.com/)
## Build status
[![Build Status](https://secure.travis-ci.org/msabramo/PHP_Counter.png?branch=master)](http://travis-ci.org/msabramo/PHP_Counter)
## Examples
```php
3
$counter['b']; // --> 2
$counter['c']; // --> 1$counter->mostCommon(2); // --> array('a' => 3, 'b' => 2)
```For the most up-to-date usage information, I suggest looking at [the
tests](/msabramo/PHP_Counter/blob/master/tests/CounterTest.php).### Running the tests
Here's how to run [the tests](/msabramo/PHP_Counter/blob/master/tests/CounterTest.php).
```
~/dev/git-repos/PHP_Counter$ phpunit --testdox .
PHPUnit 3.6.3 by Sebastian Bergmann.Counter
[x] Counter constructor with no args
[x] Counter constructor with array
[x] Counter constructor with string
[x] Increment
[x] Get array
[x] Most common
[x] Unset
[x] Missing element
[x] Elements method
[x] Update
[x] Subtract
```