Skip to content

Commit ea9fcaa

Browse files
authored
Merge pull request #6 from apacheborys/introduce-declarators
move PublicCallbackDeclarator to this repo
2 parents 713bc5f + c33d68b commit ea9fcaa

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/AbstractHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace ApacheBorys\Retry;
55

66
use ApacheBorys\Retry\Entity\Config;
7-
use ApacheBorys\Retry\HandlerExceptionDefiner\StandardHandlerExceptionDeclarator;
7+
use ApacheBorys\Retry\HandlerExceptionDeclarator\StandardHandlerExceptionDeclarator;
88
use ApacheBorys\Retry\Interfaces\HandlerExceptionDeclaratorInterface;
99

1010
abstract class AbstractHandler
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace ApacheBorys\Retry\HandlerExceptionDeclarator;
5+
6+
use ApacheBorys\Retry\Interfaces\HandlerExceptionDeclaratorInterface;
7+
8+
class PublicCallbackDeclarator implements HandlerExceptionDeclaratorInterface
9+
{
10+
/** @var callable|null $callback */
11+
private $callback = null;
12+
13+
public function initHandler(callable $callback): void
14+
{
15+
$this->callback = $callback;
16+
}
17+
18+
public function getCallback(): callable
19+
{
20+
if (is_null($this->callback)) {
21+
throw new \LogicException('Callback still not initialized. Please call `getCallback` method after `initHandler`');
22+
}
23+
24+
return $this->callback;
25+
}
26+
}

src/HandlerExceptionDefiner/StandardHandlerExceptionDeclarator.php renamed to src/HandlerExceptionDeclarator/StandardHandlerExceptionDeclarator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace ApacheBorys\Retry\HandlerExceptionDefiner;
4+
namespace ApacheBorys\Retry\HandlerExceptionDeclarator;
55

66
use ApacheBorys\Retry\Interfaces\HandlerExceptionDeclaratorInterface;
77

0 commit comments

Comments
 (0)