From 9d94980c6c0c394f7ec7039c1d28a74395ca0755 Mon Sep 17 00:00:00 2001 From: ryzr Date: Tue, 30 Jan 2018 02:22:37 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Http/Controllers/BlogController.php | 6 +++--- .../AbstractInstantArticleParser.php | 4 ++-- src/InstantArticles/DefaultParser.php | 6 +++--- src/Models/Post.php | 17 ++++++++--------- src/SluggedBlogPostMatcher.php | 5 ++--- src/SodaBlogServiceProvider.php | 4 ++-- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/Http/Controllers/BlogController.php b/src/Http/Controllers/BlogController.php index e562226..a266d08 100755 --- a/src/Http/Controllers/BlogController.php +++ b/src/Http/Controllers/BlogController.php @@ -3,7 +3,6 @@ namespace Soda\Blog\Http\Controllers; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Builder; use Soda\Blog\Models\Tag; use Soda\Blog\Models\Post; use Illuminate\Http\Request; @@ -225,11 +224,12 @@ protected function getPostSettings(Post $post) return $settings; } - protected function blogPostQuery() { + protected function blogPostQuery() + { $sortConfig = (array) config('soda.blog.default_sort'); $posts = $this->currentBlog->posts()->whereNotNull('id')->withoutGlobalScope('position')->withoutGlobalScope('published'); - if(array_keys($sortConfig)[0] == 'published_at') { + if (array_keys($sortConfig)[0] == 'published_at') { $posts->orderByRaw('published_at IS NULL DESC'); } diff --git a/src/InstantArticles/AbstractInstantArticleParser.php b/src/InstantArticles/AbstractInstantArticleParser.php index b816cbb..d7ededa 100644 --- a/src/InstantArticles/AbstractInstantArticleParser.php +++ b/src/InstantArticles/AbstractInstantArticleParser.php @@ -2,9 +2,9 @@ namespace Soda\Blog\InstantArticles; +use Soda\Blog\Models\Post; use Facebook\InstantArticles\Elements\InstantArticle; use Facebook\InstantArticles\Transformer\Transformer; -use Soda\Blog\Models\Post; abstract class AbstractInstantArticleParser implements InstantArticleParser { @@ -44,7 +44,7 @@ protected function applyRules(Transformer $transformer) } catch (\ReflectionException $e) { $factoryMethod = new \ReflectionMethod( - 'Facebook\\InstantArticles\\Transformer\\Rules\\' . $class, + 'Facebook\\InstantArticles\\Transformer\\Rules\\'.$class, 'createFrom' ); } diff --git a/src/InstantArticles/DefaultParser.php b/src/InstantArticles/DefaultParser.php index 480d41a..508903c 100644 --- a/src/InstantArticles/DefaultParser.php +++ b/src/InstantArticles/DefaultParser.php @@ -2,13 +2,13 @@ namespace Soda\Blog\InstantArticles; +use Soda\Blog\Models\Post; +use Facebook\InstantArticles\Elements\Time; use Facebook\InstantArticles\Elements\Author; use Facebook\InstantArticles\Elements\Footer; use Facebook\InstantArticles\Elements\Header; use Facebook\InstantArticles\Elements\InstantArticle; -use Facebook\InstantArticles\Elements\Time; use Facebook\InstantArticles\Transformer\Transformer; -use Soda\Blog\Models\Post; class DefaultParser extends AbstractInstantArticleParser implements InstantArticleParser { @@ -41,7 +41,7 @@ protected function applyContent(InstantArticle $article, Post $post) protected function footer(Post $post) { - return Footer::create()->withCredits('© ' . app('soda')->getApplication()->name); + return Footer::create()->withCredits('© '.app('soda')->getApplication()->name); } protected function transformContent(InstantArticle $article, $html) diff --git a/src/Models/Post.php b/src/Models/Post.php index a749f46..235a328 100755 --- a/src/Models/Post.php +++ b/src/Models/Post.php @@ -3,17 +3,17 @@ namespace Soda\Blog\Models; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\DB; +use Soda\Cms\Database\Models\User; use Illuminate\Support\Facades\URL; -use Soda\Blog\Models\Traits\BlogSortableTrait; +use Illuminate\Database\Eloquent\Model; use Soda\Blog\Models\Traits\BoundToBlog; use Soda\Cms\Database\Models\DynamicContent; -use Soda\Cms\Database\Models\Traits\Draftable; +use Illuminate\Database\Eloquent\SoftDeletes; use Soda\Cms\Database\Models\Traits\HasMedia; +use Soda\Blog\Models\Traits\BlogSortableTrait; +use Soda\Cms\Database\Models\Traits\Draftable; use Soda\Cms\Database\Models\Traits\Sluggable; -use Soda\Cms\Database\Models\User; class Post extends Model { @@ -179,7 +179,7 @@ public function getPreviousPost() { $query = static::where('id', '!=', $this->id); - foreach ((array)config('soda.blog.default_sort') as $sortableField => $direction) { + foreach ((array) config('soda.blog.default_sort') as $sortableField => $direction) { $query->where($sortableField, strtolower($direction) == 'DESC' ? '<=' : '>=', $this->$sortableField); break; @@ -192,7 +192,7 @@ public function getNextPost() { $query = static::reverseOrder()->where('id', '!=', $this->id); - foreach ((array)config('soda.blog.default_sort') as $sortableField => $direction) { + foreach ((array) config('soda.blog.default_sort') as $sortableField => $direction) { $query->where($sortableField, strtolower($direction) == 'DESC' ? '>=' : '<=', $this->$sortableField); break; @@ -212,7 +212,6 @@ public function getExcerpt($numCharacters = null, $type = 'words', $stripTags = // Return custom excerpt if auto excerpt is disabled if ($currentBlog->getSetting('auto_excerpt') !== null && $currentBlog->getSetting('auto_excerpt') == 0) { - return isset($this->attributes['excerpt']) ? $this->attributes['excerpt'] : ''; } @@ -266,7 +265,7 @@ public function getPropertiesAttribute() $propertiesModel->exists = true; foreach ($this->settings as $setting) { - if (!$setting->relationLoaded('field')) { + if (! $setting->relationLoaded('field')) { $this->settings->load('field'); } diff --git a/src/SluggedBlogPostMatcher.php b/src/SluggedBlogPostMatcher.php index f0418bb..8647820 100644 --- a/src/SluggedBlogPostMatcher.php +++ b/src/SluggedBlogPostMatcher.php @@ -2,11 +2,10 @@ namespace Soda\Blog; -use Illuminate\Contracts\Routing\Registrar as RouterContract; use Illuminate\Http\Request; -use Soda\Blog\InstantArticles\DefaultParser; use Soda\Blog\InstantArticles\InstantArticleParser; use Soda\Cms\Http\RequestMatcher\Matchers\MatcherInterface; +use Illuminate\Contracts\Routing\Registrar as RouterContract; class SluggedBlogPostMatcher implements MatcherInterface { @@ -27,7 +26,7 @@ public function matches($slug) { $blogSlug = trim($this->currentBlog->getSetting('slug'), '/'); $postSlug = trim($slug, '/'); - $postSlug = '/' . trim(substr($postSlug, strlen($blogSlug), strlen($postSlug)), '/'); + $postSlug = '/'.trim(substr($postSlug, strlen($blogSlug), strlen($postSlug)), '/'); if (ends_with($postSlug, static::INSTANT_ARTICLE_SLUG)) { $this->isInstantArticle = true; diff --git a/src/SodaBlogServiceProvider.php b/src/SodaBlogServiceProvider.php index c2a265e..c913ce5 100755 --- a/src/SodaBlogServiceProvider.php +++ b/src/SodaBlogServiceProvider.php @@ -2,14 +2,14 @@ namespace Soda\Blog; -use Soda\Blog\InstantArticles\DefaultParser; -use Soda\Blog\InstantArticles\InstantArticleParser; use Soda\Blog\Models\Blog; use Soda\Blog\Models\Post; use Soda\Blog\Console\Create; use Soda\Blog\Console\Install; use Illuminate\Support\Facades\Route; +use Soda\Blog\InstantArticles\DefaultParser; use Soda\Cms\Support\Facades\SodaFacade as Soda; +use Soda\Blog\InstantArticles\InstantArticleParser; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class SodaBlogServiceProvider extends ServiceProvider