FileCacheInstaller::install()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 1
1
<?php
2
namespace Mouf\Utils\Cache;
3
4
use Mouf\Installer\PackageInstallerInterface;
5
use Mouf\MoufManager;
6
7
/**
8
 * Installer for file cache
9
 */
10
class FileCacheInstaller implements PackageInstallerInterface {
11
12
    /**
13
     * (non-PHPdoc)
14
     * @see \Mouf\Installer\PackageInstallerInterface::install()
15
     */
16
    public static function install(MoufManager $moufManager) {
17
        if (!$moufManager->instanceExists("fileCacheService")) {
18
            $fileCacheService = $moufManager->createInstance("Mouf\\Utils\\Cache\\FileCache");
19
            $fileCacheService->setName("fileCacheService");
20
            $fileCacheService->getProperty("defaultTimeToLive")->setValue(3600);
21
            /*if ($moufManager->instanceExists("psr.errorLogLogger")) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
22
                $fileCacheService->getProperty("log")->setValue($moufManager->getInstanceDescriptor("psr.errorLogLogger"));
23
            }*/
24
        } else {
25
            $fileCacheService = $moufManager->getInstanceDescriptor("fileCacheService");
26
        }
27
28
        $configManager = $moufManager->getConfigManager();
29
        $constants = $configManager->getMergedConstants();
30
        if (isset($constants['SECRET'])) {
31
            $fileCacheService->getProperty('prefix')->setValue('SECRET')->setOrigin('config');
32
        }
33
34
        // Let's rewrite the MoufComponents.php file to save the component
35
        $moufManager->rewriteMouf();
36
    }
37
}
38
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...