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

OpcacheResetCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 10
rs 9.4285
nc 2
cc 2
eloc 5
nop 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