IDSegmentFieldModifier   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPreview() 0 8 3
A getSuggestion() 0 4 1
1
<?php
2
3
namespace SilverStripe\Forms\SegmentFieldModifier;
4
5
use SilverStripe\Forms\Form;
6
7
class IDSegmentFieldModifier extends AbstractSegmentFieldModifier
8
{
9
    /**
10
     * @inheritdoc
11
     *
12
     * @param string $value
13
     *
14
     * @return string
15
     */
16
    public function getPreview($value)
17
    {
18
        if ($this->form instanceof Form && $record = $this->form->getRecord()) {
19
            return $value . $record->ID;
20
        }
21
22
        return $value;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     *
28
     * @param string $value
29
     *
30
     * @return string
31
     */
32
    public function getSuggestion($value)
33
    {
34
        return $value;
35
    }
36
}
37