| @@ 409-418 (lines=10) @@ | ||
| 406 | * @return null |
|
| 407 | * @throws FileException on failure. |
|
| 408 | */ |
|
| 409 | public function append($content) |
|
| 410 | { |
|
| 411 | try { |
|
| 412 | if (file_put_contents($this->path, $content, \FILE_APPEND) === false) { |
|
| 413 | throw new \Exception('Failed'); |
|
| 414 | } |
|
| 415 | } catch (\Exception $e) { |
|
| 416 | throw new FileException('Can\'t append the given content.', $e->getCode(), $e); |
|
| 417 | } |
|
| 418 | } |
|
| 419 | ||
| 420 | /** |
|
| 421 | * Write the given content. |
|
| @@ 427-436 (lines=10) @@ | ||
| 424 | * @return null |
|
| 425 | * @throws FileException on failure. |
|
| 426 | */ |
|
| 427 | public function write($content) |
|
| 428 | { |
|
| 429 | try { |
|
| 430 | if (file_put_contents($this->path, $content) === false) { |
|
| 431 | throw new \Exception('Failed'); |
|
| 432 | } |
|
| 433 | } catch (\Exception $e) { |
|
| 434 | throw new FileException('Can\'t write the given content.', $e->getCode(), $e); |
|
| 435 | } |
|
| 436 | } |
|
| 437 | } |
|
| 438 | ||