Skip to content

Commit 4085e7b

Browse files
committed
Move constructor into abstract class
1 parent 547167c commit 4085e7b

5 files changed

Lines changed: 24 additions & 68 deletions

File tree

src/Builder/BuilderAbstract.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44

55
abstract class BuilderAbstract implements BuilderInterface
66
{
7+
/**
8+
* The command's name.
9+
*
10+
* @var string
11+
*/
12+
protected $command;
13+
14+
/**
15+
* Constructor. Offers an opportunity to set a command's alias/path.
16+
*
17+
* @throws InvalidArgumentException If the argument isn't a string.
18+
*/
19+
public function __construct()
20+
{
21+
$args = func_get_args();
22+
if (!empty($args)) {
23+
if (is_string($args[0])) {
24+
$this->command = $args[0];
25+
} else {
26+
throw new InvalidArgumentException('This constructor expects a string argument.');
27+
}
28+
}
29+
}
30+
731
/**
832
* Build the command string to be executed.
933
*

src/Builder/GrowlNotifyBuilder.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@ class GrowlNotifyBuilder extends BuilderAbstract
1111
*/
1212
protected $command = 'growlnotify';
1313

14-
/**
15-
* Constructor. Offers an opportunity to set a command's alias.
16-
*
17-
* @throws InvalidArgumentException If the argument isn't a string.
18-
*/
19-
public function __construct()
20-
{
21-
$args = func_get_args();
22-
if (!empty($args)) {
23-
if (is_string($args[0])) {
24-
$this->command = $args[0];
25-
} else {
26-
throw new InvalidArgumentException('This constructor expects a string argument.');
27-
}
28-
}
29-
}
30-
3114
/**
3215
* Builds the growlnotify command to be executed.
3316
*

src/Builder/GrowlNotifyWindowsBuilder.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@ class GrowlNotifyWindowsBuilder extends BuilderAbstract
1111
*/
1212
protected $command = 'growlnotify';
1313

14-
/**
15-
* Constructor. Offers an opportunity to set a command's alias.
16-
*
17-
* @throws InvalidArgumentException If the argument isn't a string.
18-
*/
19-
public function __construct()
20-
{
21-
$args = func_get_args();
22-
if (!empty($args)) {
23-
if (is_string($args[0])) {
24-
$this->command = $args[0];
25-
} else {
26-
throw new InvalidArgumentException('This constructor expects a string argument.');
27-
}
28-
}
29-
}
30-
3114
/**
3215
* Builds the growlnotify command to be executed.
3316
*

src/Builder/NotifySendBuilder.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@ class NotifySendBuilder extends BuilderAbstract
1111
*/
1212
protected $command = 'notify-send';
1313

14-
/**
15-
* Constructor. Offers an opportunity to set a command's alias.
16-
*
17-
* @throws InvalidArgumentException If the argument isn't a string.
18-
*/
19-
public function __construct()
20-
{
21-
$args = func_get_args();
22-
if (!empty($args)) {
23-
if (is_string($args[0])) {
24-
$this->command = $args[0];
25-
} else {
26-
throw new InvalidArgumentException('This constructor expects a string argument.');
27-
}
28-
}
29-
}
30-
3114
/**
3215
* Builds the notify-send command to be executed.
3316
*

src/Builder/TerminalNotifierBuilder.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@ class TerminalNotifierBuilder extends BuilderAbstract
1111
*/
1212
protected $command = 'terminal-notifier';
1313

14-
/**
15-
* Constructor. Offers an opportunity to set a command's alias.
16-
*
17-
* @throws InvalidArgumentException If the argument isn't a string.
18-
*/
19-
public function __construct()
20-
{
21-
$args = func_get_args();
22-
if (!empty($args)) {
23-
if (is_string($args[0])) {
24-
$this->command = $args[0];
25-
} else {
26-
throw new InvalidArgumentException('This constructor expects a string argument.');
27-
}
28-
}
29-
}
30-
3114
/**
3215
* Builds the terminal-notifier command to be executed.
3316
*

0 commit comments

Comments
 (0)