Completed
Push — master ( d535d3...8c6cf6 )
by Felix
16:53
created

Tx_FeatureFlag_System_Typo3_CacheManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 29
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A clearAllCaches() 0 8 1
1
<?php
2
3
/***************************************************************
4
 *  Copyright notice
5
 *
6
 *  (c) 2016 AOE GmbH <[email protected]>
7
 *
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
/**
28
 * @package FeatureFlag
29
 * @subpackage System_Typo3
30
 */
31
class Tx_FeatureFlag_System_Typo3_CacheManager
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
32
{
33
    /**
34
     * @var \TYPO3\CMS\Extbase\Object\ObjectManager
35
     */
36
    private $objectManager;
37
38
    /**
39
     * Tx_FeatureFlag_System_Typo3_Cache constructor.
40
     * @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager
41
     */
42
    public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
43
    {
44
        $this->objectManager = $objectManager;
45
    }
46
47
    /**
48
     * Clear all caches. Therefor it is necessary to login a BE_USER. You have to prevent
49
     * this function to run on live systems!!!
50
     */
51
    public function clearAllCaches()
52
    {
53
        /** @var TYPO3\CMS\Core\DataHandling\DataHandler $tce */
54
        $tce = $this->objectManager->get(TYPO3\CMS\Core\DataHandling\DataHandler::class);
55
        $tce->start(array(), array());
56
        $tce->admin = 1;
0 ignored issues
show
Documentation Bug introduced by
The property $admin was declared of type boolean, but 1 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
57
        $tce->clear_cacheCmd('all');
58
    }
59
}