Created
March 1, 2012 13:46
-
-
Save davedevelopment/1949917 to your computer and use it in GitHub Desktop.
Audio notifier for Sismo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Sismo\Notifier; | |
use Sismo\Commit; | |
/** | |
* A simple audio notifier for Sismo | |
* | |
* (c) Dave Marshall <[email protected]> | |
* | |
*/ | |
class AudioNotifier extends Notifier | |
{ | |
/** | |
* Success | |
*/ | |
protected $success; | |
/** | |
* Failure | |
*/ | |
protected $failure; | |
/** | |
* Command | |
*/ | |
protected $command; | |
/** | |
* Constructor | |
* | |
* @param string $success - path to success sound | |
* @param string $failure - path to failure sound | |
* @param string $command - optional sprintf format string for command | |
*/ | |
public function __construct($success, $failure, $command = 'mplayer "%s" > /dev/null 2>&1 ') | |
{ | |
$this->success = realpath($success); | |
$this->failure = realpath($failure); | |
$this->command = $command; | |
} | |
/** | |
* {@inheritDoc} | |
*/ | |
public function notify(Commit $commit) | |
{ | |
$file = $commit->isSuccessful() ? $this->success : $this->failure; | |
exec(sprintf($this->command, $file)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment