These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /* |
||
3 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
4 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
5 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
6 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
7 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
8 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
9 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
10 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
11 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
12 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
14 | * |
||
15 | * This software consists of voluntary contributions made by many individuals |
||
16 | * and is licensed under the MIT license. |
||
17 | */ |
||
18 | |||
19 | namespace StrokerCache; |
||
20 | |||
21 | use Zend\Console\Adapter\AdapterInterface; |
||
22 | use Zend\EventManager\EventInterface; |
||
23 | use Zend\ModuleManager\Feature; |
||
24 | |||
25 | class Module implements |
||
0 ignored issues
–
show
|
|||
26 | Feature\ConfigProviderInterface, |
||
27 | Feature\ConsoleBannerProviderInterface, |
||
28 | Feature\ConsoleUsageProviderInterface, |
||
29 | Feature\AutoloaderProviderInterface, |
||
30 | Feature\BootstrapListenerInterface |
||
31 | { |
||
32 | |||
33 | /** |
||
34 | * {@inheritDoc} |
||
35 | */ |
||
36 | public function getConfig() |
||
37 | { |
||
38 | return include __DIR__ . '/config/module.config.php'; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritDoc} |
||
43 | */ |
||
44 | public function getAutoloaderConfig() |
||
45 | { |
||
46 | return array( |
||
47 | 'Zend\Loader\StandardAutoloader' => array( |
||
48 | 'namespaces' => array( |
||
49 | __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, |
||
50 | ), |
||
51 | ), |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | public function onBootstrap(EventInterface $e) |
||
59 | { |
||
60 | /** @var $application \Zend\Mvc\Application */ |
||
61 | $application = $e->getParam('application'); |
||
62 | $listener = $application->getServiceManager()->get('StrokerCache\Listener\CacheListener'); |
||
63 | |||
64 | $application->getEventManager()->attach($listener); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritDoc} |
||
69 | */ |
||
70 | public function getConsoleBanner(AdapterInterface $console) |
||
71 | { |
||
72 | return 'StrokerCache ' . Version::VERSION; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritDoc} |
||
77 | */ |
||
78 | public function getConsoleUsage(AdapterInterface $console) |
||
79 | { |
||
80 | return array( |
||
81 | 'Usage:', |
||
82 | 'strokercache clear <tags>' => 'Invalidate cache items by tags', |
||
83 | |||
84 | array('<tags>' => 'List of tags, optionally separated by commas') |
||
85 | ); |
||
86 | } |
||
87 | } |
||
88 |
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.