RobotsRow   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generateArray() 0 8 1
A __construct() 0 4 1
1
<?php
2
3
namespace Mguinea\Robots\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Mguinea\Robots\Robots;
7
8
class RobotsRow extends Model
9
{
10
    protected $fillable = ['action', 'type'];
11
12
    protected $guarded = ['id'];
13
14
    public function __construct(array $attributes = [])
15
    {
16
        parent::__construct($attributes);
17
        $this->setTable(config('laravel-robots.table_names.robot_rows'));
18
    }
19
20
    /**
21
     * Generates an array from DB data, compatible with Robots constructor.
22
     *
23
     * @return array
24
     */
25
    public static function generateArray(): array
26
    {
27
        return [
28
            'allows' => static::where('type', Robots::ALLOW)->get('action')->toArray(),
29
            'disallows' => static::where('type', Robots::DISALLOW)->get('action')->toArray(),
30
            'hosts' => static::where('type', Robots::HOST)->get('action')->toArray(),
31
            'sitemaps' => static::where('type', Robots::SITEMAP)->get('action')->toArray(),
32
            'userAgents' => static::where('type', Robots::USER_AGENT)->get('action')->toArray(),
33
        ];
34
    }
35
}
36