SoapPanel   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 57
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getLabel() 0 4 1
A save() 0 4 1
A getDetail() 0 10 1
A logSoapRequest() 0 13 4
1
<?php
2
namespace bedezign\yii2\audit\panels;
3
4
use Yii;
5
use bedezign\yii2\audit\models\AuditError;
6
use bedezign\yii2\audit\components\panels\DataStoragePanel;
7
use yii\data\ArrayDataProvider;
8
9
/**
10
 * Class CurlPanel
11
 * @package bedezign\yii2\audit\src\panels
12
 */
13
class SoapPanel extends DataStoragePanel
14
{
15
    public function getName()
16
    {
17
        return Yii::t('audit', 'SOAP');
18
    }
19
20
    /**
21
     * @inheritdoc
22
     */
23
    public function getLabel()
24
    {
25
        return $this->getName() . ' <small>(' . count($this->data) . ')</small>';
26
    }
27
28
    /**
29
     * Receives a bunch of information about a SOAP request and logs it.
30
     * If you are unable to use the modules' SoapClient class you can call this function manually to log the data.
31
     *
32
     * @param array $data
33
     */
34
    public function logSoapRequest($data)
35
    {
36
        $this->module->registerPanel($this);
37
38
        if (!is_array($this->data))
39
            $this->data = [];
40
41
        if (isset($data['error'])) {
42
            $error = $this->module->exception($data['error']);
43
            $data['error'] = [$data['error']->faultcode, $error ? $error->id : null];
44
        }
45
        $this->data[] = array_filter($data);
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function save()
52
    {
53
        return $this->data;
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function getDetail()
60
    {
61
        $dataProvider = new ArrayDataProvider();
62
        $dataProvider->allModels = $this->data;
63
64
        return Yii::$app->view->render('panels/soap/index', [
65
            'panel'        => $this,
66
            'dataProvider' => $dataProvider,
67
        ]);
68
    }
69
}