Skip to content

Commit

Permalink
Move constructor into abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
bcrowe committed Jan 6, 2015
1 parent 547167c commit 4085e7b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 68 deletions.
24 changes: 24 additions & 0 deletions src/Builder/BuilderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@

abstract class BuilderAbstract implements BuilderInterface
{
/**
* The command's name.
*
* @var string
*/
protected $command;

/**
* Constructor. Offers an opportunity to set a command's alias/path.
*
* @throws InvalidArgumentException If the argument isn't a string.
*/
public function __construct()
{
$args = func_get_args();
if (!empty($args)) {
if (is_string($args[0])) {
$this->command = $args[0];
} else {
throw new InvalidArgumentException('This constructor expects a string argument.');
}
}
}

/**
* Build the command string to be executed.
*
Expand Down
17 changes: 0 additions & 17 deletions src/Builder/GrowlNotifyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ class GrowlNotifyBuilder extends BuilderAbstract
*/
protected $command = 'growlnotify';

/**
* Constructor. Offers an opportunity to set a command's alias.
*
* @throws InvalidArgumentException If the argument isn't a string.
*/
public function __construct()
{
$args = func_get_args();
if (!empty($args)) {
if (is_string($args[0])) {
$this->command = $args[0];
} else {
throw new InvalidArgumentException('This constructor expects a string argument.');
}
}
}

/**
* Builds the growlnotify command to be executed.
*
Expand Down
17 changes: 0 additions & 17 deletions src/Builder/GrowlNotifyWindowsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ class GrowlNotifyWindowsBuilder extends BuilderAbstract
*/
protected $command = 'growlnotify';

/**
* Constructor. Offers an opportunity to set a command's alias.
*
* @throws InvalidArgumentException If the argument isn't a string.
*/
public function __construct()
{
$args = func_get_args();
if (!empty($args)) {
if (is_string($args[0])) {
$this->command = $args[0];
} else {
throw new InvalidArgumentException('This constructor expects a string argument.');
}
}
}

/**
* Builds the growlnotify command to be executed.
*
Expand Down
17 changes: 0 additions & 17 deletions src/Builder/NotifySendBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ class NotifySendBuilder extends BuilderAbstract
*/
protected $command = 'notify-send';

/**
* Constructor. Offers an opportunity to set a command's alias.
*
* @throws InvalidArgumentException If the argument isn't a string.
*/
public function __construct()
{
$args = func_get_args();
if (!empty($args)) {
if (is_string($args[0])) {
$this->command = $args[0];
} else {
throw new InvalidArgumentException('This constructor expects a string argument.');
}
}
}

/**
* Builds the notify-send command to be executed.
*
Expand Down
17 changes: 0 additions & 17 deletions src/Builder/TerminalNotifierBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ class TerminalNotifierBuilder extends BuilderAbstract
*/
protected $command = 'terminal-notifier';

/**
* Constructor. Offers an opportunity to set a command's alias.
*
* @throws InvalidArgumentException If the argument isn't a string.
*/
public function __construct()
{
$args = func_get_args();
if (!empty($args)) {
if (is_string($args[0])) {
$this->command = $args[0];
} else {
throw new InvalidArgumentException('This constructor expects a string argument.');
}
}
}

/**
* Builds the terminal-notifier command to be executed.
*
Expand Down

0 comments on commit 4085e7b

Please sign in to comment.