- gitlist.git
- src
- Gitter
- Statistics
- Contributors.php
This file ( 929B ) exceeds the allowed full mode (48 kb) size.
The editor full hight is disabled, only scrolling is allowed..
If you wish to edit a file, it is recommended to use the scroll mode as some users do not like the full height
mode, although some users like it.
<?php
namespace Gitter\Statistics;
use Gitter\Util\Collection;
use Gitter\Model\Commit\Commit;
/**
* Aggregate statistics based on contributor
*/
class Contributors extends Collection implements StatisticsInterface
{
/**
* @param Commit $commit
*/
public function addCommit(Commit $commit)
{
$email = $commit->getAuthor()->getEmail();
$commitDate = $commit->getCommiterDate()->format('Y-m-d');
if (!isset($this->items[$email])) {
$this->items[$email] = new Collection;
}
$this->items[$email]->items[$commitDate][] = $commit;
ksort($this->items[$email]->items);
}
public function sortCommits()
{
uasort($this->items, function ($sortA, $sortB) {
if (count($sortA) === count($sortB)) {
return 0;
}
return count($sortA) > count($sortB) ? -1 : 1;
});
}
}