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

OpcacheResetCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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