Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. use Sismo\Notifier;
  4. use Sismo\Commit;
  5.  
  6. /**
  7.  * A simple audio notifier for Sismo
  8.  *
  9.  * (c) Dave Marshall <dave.marshall@atstsolutions.co.uk>
  10.  *
  11.  */
  12. class AudioNotifier extends Notifier
  13. {
  14.     /**
  15.      * Success
  16.      */
  17.     protected $success;
  18.  
  19.     /**
  20.      * Failure
  21.      */
  22.     protected $failure;
  23.  
  24.     /**
  25.      * Command
  26.      */
  27.     protected $command;
  28.  
  29.     /**
  30.      * Constructor
  31.      *
  32.      * @param string $success - path to success sound
  33.      * @param string $failure - path to failure sound
  34.      * @param string $command - optional sprintf format string for command
  35.      */
  36.     public function __construct($success, $failure, $command = 'mplayer "%s" > /dev/null 2>&1 ')
  37.     {
  38.         $this->success = realpath($success);
  39.         $this->failure = realpath($failure);
  40.         $this->command = $command;
  41.     }
  42.  
  43.     /**
  44.      * {@inheritDoc}
  45.      */
  46.     public function notify(Commit $commit)
  47.     {
  48.         $file = $commit->isSuccessful() ? $this->success : $this->failure;
  49.         exec(sprintf($this->command, $file));
  50.     }
  51. }