]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/bookmark/exception/InvalidBookmarkException.php
Apply PHP Code Beautifier on source code for linter automatic fixes
[github/shaarli/Shaarli.git] / application / bookmark / exception / InvalidBookmarkException.php
CommitLineData
336a28fa
A
1<?php
2
3namespace Shaarli\Bookmark\Exception;
4
5use Shaarli\Bookmark\Bookmark;
6
7class InvalidBookmarkException extends \Exception
8{
9 public function __construct($bookmark)
10 {
11 if ($bookmark instanceof Bookmark) {
12 if ($bookmark->getCreated() instanceof \DateTime) {
13 $created = $bookmark->getCreated()->format(\DateTime::ATOM);
14 } elseif (empty($bookmark->getCreated())) {
15 $created = '';
16 } else {
17 $created = 'Not a DateTime object';
18 }
53054b2b
A
19 $this->message = 'This bookmark is not valid' . PHP_EOL;
20 $this->message .= ' - ID: ' . $bookmark->getId() . PHP_EOL;
21 $this->message .= ' - Title: ' . $bookmark->getTitle() . PHP_EOL;
22 $this->message .= ' - Url: ' . $bookmark->getUrl() . PHP_EOL;
23 $this->message .= ' - ShortUrl: ' . $bookmark->getShortUrl() . PHP_EOL;
24 $this->message .= ' - Created: ' . $created . PHP_EOL;
336a28fa 25 } else {
53054b2b 26 $this->message = 'The provided data is not a bookmark' . PHP_EOL;
336a28fa
A
27 $this->message .= var_export($bookmark, true);
28 }
29 }
30}