jacobemerick /
web
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | require_once __DIR__ . '/../index.php'; |
||
| 4 | |||
| 5 | use Jacobemerick\Web\Domain\Stream\Blog\MysqlBlogRepository as BlogRepository; |
||
| 6 | use Jacobemerick\Web\Domain\Stream\BlogComment\MysqlBlogCommentRepository as BlogCommentRepository; |
||
| 7 | |||
| 8 | $blogRepository = new BlogRepository($container['db_connection_locator']); |
||
| 9 | $mostRecentBlog = $blogRepository->getBlogs(1); |
||
| 10 | $mostRecentBlog = current($mostRecentBlog); |
||
| 11 | $mostRecentBlogDateTime = $mostRecentBlog['datetime']; |
||
| 12 | $mostRecentBlogDateTime = new DateTime($mostRecentBlogDateTime); |
||
| 13 | |||
| 14 | $blogFeed = Feed::loadRss('http://blog.jacobemerick.com/rss.xml'); |
||
| 15 | View Code Duplication | foreach ($blogFeed->item as $item) { |
|
| 16 | $datetime = new DateTime($item->pubDate); |
||
| 17 | if ($datetime <= $mostRecentBlogDateTime) { |
||
|
0 ignored issues
–
show
|
|||
| 18 | // break; |
||
| 19 | } |
||
| 20 | |||
| 21 | $uniqueBlogCheck = $blogRepository->getBlogByPermalink((string) $item->guid); |
||
| 22 | if ($uniqueBlogCheck !== false) { |
||
| 23 | continue; |
||
| 24 | } |
||
| 25 | |||
| 26 | $datetime->setTimezone($container['default_timezone']); |
||
| 27 | $metadata = json_decode(json_encode($item), true); |
||
| 28 | |||
| 29 | $blogRepository->insertBlog( |
||
| 30 | (string) $item->guid, |
||
| 31 | $datetime, |
||
| 32 | $metadata |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | |||
| 36 | $blogCommentRepository = new BlogCommentRepository($container['db_connection_locator']); |
||
| 37 | $mostRecentBlogComment = $blogCommentRepository->getBlogComments(1); |
||
| 38 | $mostRecentBlogComment = current($mostRecentBlogComment); |
||
| 39 | $mostRecentBlogCommentDateTime = $mostRecentBlogComment['datetime']; |
||
| 40 | $mostRecentBlogCommentDateTime = new DateTime($mostRecentBlogCommentDateTime); |
||
| 41 | |||
| 42 | $commentFeed = Feed::loadRss('http://blog.jacobemerick.com/rss-comments.xml'); |
||
| 43 | View Code Duplication | foreach ($commentFeed->item as $item) { |
|
| 44 | $datetime = new DateTime($item->pubDate); |
||
| 45 | if ($datetime <= $mostRecentBlogCommentDateTime) { |
||
| 46 | break; |
||
| 47 | } |
||
| 48 | |||
| 49 | $uniqueBlogCommentCheck = $blogCommentRepository->getBlogCommentByPermalink((string) $item->guid); |
||
| 50 | if ($uniqueBlogCommentCheck !== false) { |
||
| 51 | continue; |
||
| 52 | } |
||
| 53 | |||
| 54 | $datetime->setTimezone($container['default_timezone']); |
||
| 55 | $metadata = json_decode(json_encode($item), true); |
||
| 56 | |||
| 57 | $blogCommentRepository->insertBlogComment( |
||
| 58 | (string) $item->guid, |
||
| 59 | $datetime, |
||
| 60 | $metadata |
||
| 61 | ); |
||
| 62 | } |
||
| 63 |
This check looks for the bodies of
ifstatements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
ifbodies can be removed. If you have an empty if but statements in theelsebranch, consider inverting the condition.could be turned into
This is much more concise to read.