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

Secure::protectDatas()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
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