Test Setup Failed
Push — master ( 81f5ad...e23419 )
by Terzi
04:23
created

BelongsToMany   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tagList() 0 6 1
A useAsTitle() 0 5 1
1
<?php
2
3
namespace Terranet\Administrator\Field;
4
5
use Terranet\Administrator\Modules\Faked;
6
7
class BelongsToMany extends HasMany
8
{
9
    const MODE_TAGS = 'tags';
10
    const MODE_CHECKBOXES = 'checkboxes';
11
12
    /** @var string */
13
    protected $icon = 'random';
14
15
    /** @var string */
16
    protected $titleField = 'name';
17
18
    /** @var string */
19
    protected $editMode = self::MODE_CHECKBOXES;
20
21
    /** @var bool */
22
    protected $completeList = true;
23
24
    /**
25
     * Show editable controls as checkboxes.
26
     *
27
     * @return self
28
     */
29
    public function tagList(): self
30
    {
31
        $this->editMode = static::MODE_TAGS;
32
        $this->completeList = false;
33
34
        return $this;
35
    }
36
37
    /**
38
     * @param string $column
39
     * @return BelongsToMany
40
     */
41
    public function useAsTitle(string $column): BelongsToMany
42
    {
43
        $this->titleField = $column;
44
45
        return $this;
46
    }
47
}
48