ProxyDBExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 1

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;
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