Completed
Push — 1.x ( 2f995a...fa8c59 )
by Samuel
18:04
created

OpcacheResetCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 0
cbo 2
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of CacheTool.
5
 *
6
 * (c) Samuel Gordalina <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CacheTool\Command;
13
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class OpcacheResetCommand extends AbstractCommand
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function configure()
23
    {
24
        $this
25
            ->setName('opcache:reset')
26
            ->setDescription('Resets the contents of the opcode cache')
27
            ->setHelp('');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $this->ensureExtensionLoaded('Zend OPcache');
36
37
        $success = $this->getCacheTool()->opcache_reset();
38
39
        if (!$success) {
40
            throw new \RuntimeException('opcache_reset(): No Opcache status info available.  Perhaps Opcache is disabled via opcache.enable or opcache.enable_cli?');
41
        }
42
    }
43
}
44