for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace andmemasin\helpers;
class QuickGit
{
/** @var int */
private $major = 1;
private $minor = 0;
/** @var string */
private $patch = '';
private $commits = 0;
private $commit = '';
/**
* @method __construct
*/
public function __construct()
// Collect git data.
exec('git describe --always', $gitHashShort);
$this->patch = $gitHashShort;
exec('git rev-list HEAD | wc -l', $gitCommits);
$this->commits = $gitCommits;
exec('git log -1', $gitHashLong);
$this->commit = $gitHashLong;
}
* @return string
public function toString($format = 'short')
switch ($format) {
case 'long':
return sprintf(
'%d.%d.%s (#%d, %s)',
$this->major,
$this->minor,
$this->patch,
$this->commits,
$this->commit
);
default:
'%d.%d.%s',
$this->patch
* @method __toString
public function __toString()
return $this->toString();