IDSegmentFieldModifier::getPreview()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 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