Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f41eb23

Browse files
committed
Add InvalidWatcherException::getWatcherId
Resolves #98. I guess this exception should only be thrown if the passed watcher identifier is a string. If a wrong type is passed, some other exception should be thrown.
1 parent aef839e commit f41eb23

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Loop/InvalidWatcherException.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,29 @@
99
*/
1010
class InvalidWatcherException extends \Exception
1111
{
12+
/** @var string */
13+
private $watcherId;
1214

15+
/**
16+
* @param string $watcherId The watcher identifier.
17+
* @param string|null $message The exception message.
18+
*/
19+
public function __construct($watcherId, $message = null)
20+
{
21+
$this->watcherId = $watcherId;
22+
23+
if ($message === null) {
24+
$message = "An invalid watcher idenfier has been used: '{$watcherId}'";
25+
}
26+
27+
parent::__construct($message);
28+
}
29+
30+
/**
31+
* @return string The watcher identifier.
32+
*/
33+
public function getWatcherId()
34+
{
35+
return $this->watcherId;
36+
}
1337
}

0 commit comments

Comments
 (0)