PostAuthors   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A all() 0 14 3
1
<?php
2
3
namespace App\Services;
4
5
use App\Models\Post;
6
use App\Models\User;
7
8
class PostAuthors
9
{
10
    /**
11
     * Get all the authors as a collection.
12
     *
13
     * @return
14
     */
15
    public static function all()
16
    {
17
        $usernames = User::userNames()->get();
18
        $authors = Post::authors()->get();
19
        $allAvailableAuthors = collect([]);
20
21
        foreach ($authors as $author) {
22
            $allAvailableAuthors[] = $author->author;
23
        }
24
        foreach ($usernames as $username) {
25
            $allAvailableAuthors[] = $username->name;
26
        }
27
28
        return $allAvailableAuthors->unique()->sort()->all();
29
    }
30
}
31