1 | <?php |
||
10 | class MemoryLimitExitStrategy implements ExitStrategy |
||
11 | { |
||
12 | private $memoryLimit; |
||
13 | |||
14 | /** |
||
15 | * @param int $memoryLimit The memory limit in MB - will exit if exceeded |
||
16 | */ |
||
17 | 9 | public function __construct($memoryLimit) |
|
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 4 | public function shouldExit($count) |
|
26 | { |
||
27 | if (memory_get_usage() >= $this->memoryLimit) { |
||
28 | 3 | return true; |
|
29 | } |
||
30 | |||
31 | 4 | return false; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 3 | public function getReason() |
|
41 | } |
||
42 |