ExistingCoreChanges::getBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sugarcrm\UpgradeSpec\Element\Section;
4
5
use Sugarcrm\UpgradeSpec\Element\ElementInterface;
6
use Sugarcrm\UpgradeSpec\Context\Upgrade;
7
use Sugarcrm\UpgradeSpec\Template\RendererAwareInterface;
8
use Sugarcrm\UpgradeSpec\Template\RendererAwareTrait;
9
10
class ExistingCoreChanges implements ElementInterface, RendererAwareInterface
11
{
12
    use RendererAwareTrait;
13
14
    /**
15
     * @return string
16
     */
17
    public function getTitle()
18
    {
19
        return 'Review / rewrite existing core changes';
20
    }
21
22
    /**
23
     * @return int
24
     */
25
    public function getOrder()
26
    {
27
        return 2;
28
    }
29
30
    /**
31
     * @param Upgrade $context
32
     *
33
     * @return bool
34
     */
35
    public function isRelevantTo(Upgrade $context)
36
    {
37
        return true;
38
    }
39
40
    /**
41
     * @param Upgrade $context
42
     *
43
     * @return string
44
     */
45
    public function getBody(Upgrade $context)
46
    {
47
        $guideUrl = $this->getExtensionsGuideUrl($context->getTargetVersion());
48
49
        return $this->renderer->render('existing_core_changes', [
50
            'dev_guide_url' => $guideUrl
51
        ]);
52
    }
53
54
    /**
55
     * Get extensions dev guide url for given version.
56
     *
57
     * @param $version
58
     *
59
     * @return string
60
     */
61
    private function getExtensionsGuideUrl($version)
62
    {
63
        $guideUrl = 'http://support.sugarcrm.com/Documentation/Sugar_Developer/';
64
        list($v1, $v2) = explode('.', $version);
65
        $baseVersion = $v1 . '.' . $v2;
66
67
        if (version_compare($baseVersion, '6.5', '<') || version_compare($baseVersion, '7.8', '>')) {
68
            return '';
69
        }
70
71
        if (version_compare($baseVersion, '7.0', '<')) {
72
            $guideUrl .= 'Sugar_Developer_Guide_6.5/Extension_Framework/index.html';
73
        } elseif (version_compare($baseVersion, '7.7', '<')) {
74
            $guideUrl .= 'Sugar_Developer_Guide_7.6/Extension_Framework/index.html';
75
        } else {
76
            $guideUrl .= sprintf('Sugar_Developer_Guide_%s/Architecture/index.html#Extensions', $baseVersion);
77
        }
78
79
        return $guideUrl;
80
    }
81
}
82