public
Created

Audio notifier for Sismo

  • Download Gist
AudioNotifier.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<?php
 
use Sismo\Notifier;
use Sismo\Commit;
 
/**
* A simple audio notifier for Sismo
*
* (c) Dave Marshall <dave.marshall@atstsolutions.co.uk>
*
*/
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));
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.