Completed
Branch master (b67f97)
by Pierre-Henry
35:51
created

AnalyticsApiFormProcess::clearCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author         Pierre-Henry Soria <[email protected]>
4
 * @copyright      (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
5
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package        PH7 / App / System / Module / Admin / From / Processing
7
 */
8
namespace PH7;
9
10
defined('PH7') or die('Restricted access');
11
12
use
0 ignored issues
show
Coding Style introduced by
There must be a single space after the USE keyword
Loading history...
13
PH7\Framework\Mvc\Model\Design,
14
PH7\Framework\Mvc\Model\Analytics,
15
PH7\Framework\Cache\Cache,
16
PH7\Framework\Mvc\Request\Http;
17
18
class AnalyticsApiFormProcess extends Form
19
{
20
    public function __construct()
21
    {
22
        parent::__construct();
23
24
        if (!$this->str->equals(
25
            $this->httpRequest->post('code', Http::NO_CLEAN),
26
            (new Design)->analyticsApi(false))
27
        ) {
28
            (new Analytics)->updateApi($this->httpRequest->post('code', Http::NO_CLEAN));
29
            $this->clearCache();
30
        }
31
        \PFBC\Form::setSuccess('form_analytics', t('Analytics Code updated!'));
32
    }
33
34
    /**
35
     * Clear the 'active' "analyticsApi" data
36
     *
37
     * @return void
38
     */
39
    private function clearCache()
40
    {
41
        (new Cache)->start(Design::CACHE_STATIC_GROUP, 'analyticsApi1', null)->clear();
42
    }
43
}
44