Completed
Pull Request — master (#83)
by Sebastian
04:16
created

ArticleRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTopLevel() 0 7 1
A getSiblings() 0 7 1
A firstChild() 0 7 1
A findSpecialArticle() 0 4 1
1
<?php
2
3
namespace App\Repositories;
4
5
use App\Models\Article;
6
use App\Models\Enums\SpecialArticle;
7
use Illuminate\Support\Collection;
8
9
class ArticleRepository
10
{
11
    public function getTopLevel(): Collection
12
    {
13
        return Article::all()
14
            ->whereNull('parent_id')
15
            ->orderBy('order_column')
16
            ->get();
17
    }
18
19
    public function getSiblings(Article $article): Collection
20
    {
21
        return Article::all()
22
            ->where('parent_id', $article->parent_id)
23
            ->orderBy('order_column')
24
            ->get();
25
    }
26
27
    public function firstChild(Article $article): Article
28
    {
29
        return Article::all()
30
            ->where('parent_id', $article->id)
31
            ->orderBy('order_column')
32
            ->first();
33
    }
34
35
    /**
36
     * @param \App\Models\Enums\SpecialArticle $specialArticle
37
     *
38
     * @return \App\Models\Article|null
39
     */
40
    public function findSpecialArticle(SpecialArticle $specialArticle)
41
    {
42
        return $this->query()->where('technical_name', $specialArticle)->first();
0 ignored issues
show
Bug introduced by
The method query() does not seem to exist on object<App\Repositories\ArticleRepository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
    }
44
}
45