Passed
Pull Request — master (#18)
by Robbie
03:25
created

ProxyDBExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateProxy() 0 6 1
1
<?php
2
3
namespace SilverStripe\Auditor\Extensions;
4
5
use SilverStripe\Auditor\AuditHook;
6
use SilverStripe\Core\Extension;
7
use TractorCow\ClassProxy\Generators\ProxyGenerator;
0 ignored issues
show
Bug introduced by
The type TractorCow\ClassProxy\Generators\ProxyGenerator 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...
8
9
class ProxyDBExtension extends Extension
10
{
11
    /**
12
     * Bind a proxy callback into the Database::manipulate method to allow us to track database activity
13
     * for the {@link AuditHook} class
14
     *
15
     * @param ProxyGenerator $proxy
16
     */
17
    public function updateProxy(ProxyGenerator &$proxy)
18
    {
19
        $proxy = $proxy->addMethod('manipulate', function ($args, $next) {
20
            $manipulation = $args[0];
21
            AuditHook::handle_manipulation($manipulation);
22
            return $next(...$args);
23
        });
24
    }
25
}
26