action_plugin_geophp   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 9
c 2
b 1
f 0
dl 0
loc 26
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A popularity() 0 9 1
1
<?php
2
3
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
4
// phpcs:disable PSR1.Files.SideEffects
5
/*
6
* Copyright (c) 2022 Mark C. Prins <[email protected]>
7
*
8
* Permission to use, copy, modify, and distribute this software for any
9
* purpose with or without fee is hereby granted, provided that the above
10
* copyright notice and this permission notice appear in all copies.
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
*
20
*/
21
use dokuwiki\Extension\Plugin;
0 ignored issues
show
Bug introduced by
The type dokuwiki\Extension\Plugin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use dokuwiki\Extension\EventHandler;
0 ignored issues
show
Bug introduced by
The type dokuwiki\Extension\EventHandler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use dokuwiki\Extension\Event;
0 ignored issues
show
Bug introduced by
The type dokuwiki\Extension\Event was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
This use statement conflicts with another class in this namespace, Event. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
24
use Composer\InstalledVersions;
25
26
require_once __DIR__ . '/vendor/autoload.php';
27
28
/**
29
 * DokuWiki Plugin geophp (Action Component).
30
 *
31
 * @author Mark Prins
32
 */
33
class action_plugin_geophp extends Plugin
34
{
35
    /**
36
     * plugin should use this method to register its handlers with the DokuWiki's event controller
37
     *
38
     * @param    $controller DokuWiki's event controller object. Also available as global $EVENT_HANDLER
0 ignored issues
show
Documentation Bug introduced by
The doc comment DokuWiki's at position 0 could not be parsed: Unknown type name 'DokuWiki's' at position 0 in DokuWiki's.
Loading history...
39
     */
40
    final public function register(EventHandler $controller): void
41
    {
42
        $controller->register_hook('PLUGIN_POPULARITY_DATA_SETUP', 'AFTER', $this, 'popularity');
43
    }
44
45
    /**
46
     * Produce popularity data for this plugin.
47
     *
48
     * @param Event $event The DokuWiki event
49
     */
50
    final public function popularity(Event $event): void
51
    {
52
        $versionInfo = getVersionData();
53
        $geoPHP = InstalledVersions::getPrettyVersion('funiq/geophp');
54
        $plugin_info = $this->getInfo();
55
        $event->data['geophp']['version'] = $plugin_info['date'];
56
        $event->data['geophp']['geophp'] = $geoPHP;
57
        $event->data['geophp']['dwversion'] = $versionInfo['date'];
58
        $event->data['geophp']['combinedversion'] = $versionInfo['date'] . '_' . $plugin_info['date'] . '_' . $geoPHP;
59
    }
60
}
61