Completed
Push — 2.0 ( bddf1c )
by Vermeulen
02:18
created

Secure   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 23
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A protectDatas() 0 11 2
1
<?php
2
3
namespace BfwSql\Helpers;
4
5
use \Exception;
6
7
/**
8
 * Helpers to securize data
9
 */
10
class Secure
11
{
12
    /**
13
     * Protect datas with sql protect method
14
     * 
15
     * @param string $datas Datas to protect
16
     * 
17
     * @return string
18
     * 
19
     * @throw \Exception If no database connected
20
     */
21
    public static function protectDatas($datas)
22
    {
23
        $app      = \BFW\Application::getInstance();
24
        $dbModule = $app->getModule('bfw-api');
25
        
26
        if (count($dbModule->listBases) === 0) {
27
            throw new Exception('No database connected to protect data');
28
        }
29
        
30
        return $dbModule->listBases[0]->protect($datas);
31
    }
32
}
33