SynonymSet   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A requireDefaultRecords() 0 9 2
1
<?php
2
/**
3
 * class SynonymSet|Firesphere\ElasticSearch\Models\SynonymSet Index items from the CMS through a QueuedJob
4
 *
5
 * @package Firesphere\Elastic\Search
6
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
7
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
8
 */
9
10
namespace Firesphere\ElasticSearch\Models;
11
12
use SilverStripe\ORM\DataObject;
13
use SilverStripe\ORM\FieldType\DBVarchar;
14
use SilverStripe\ORM\UniqueKey\UniqueKeyService;
15
16
/**
17
 * Class \Firesphere\ElasticSearch\Models\SynonymSet
18
 *
19
 * @property string $Name
20
 * @property string $Key
21
 */
22
class SynonymSet extends DataObject
23
{
24
    private static $table_name = 'SynonymSet';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
25
26
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
27
        'Name' => DBVarchar::class,
28
        'Key'  => DBVarchar::class
29
    ];
30
31
    public function requireDefaultRecords()
32
    {
33
        if (!self::get()->count()) {
34
            self::create([
35
                'Name' => 'Default',
36
                'Key'  => UniqueKeyService::singleton()->generateKey($this)
37
            ])->write();
38
        }
39
        parent::requireDefaultRecords();
40
    }
41
}
42