Completed
Push — master ( 78ff93...a59b40 )
by Jared
19:33
created

ModelDriver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A __invoke() 0 4 1
1
<?php
2
3
/**
4
 * @author Jared King <[email protected]>
5
 *
6
 * @link http://jaredtking.com
7
 *
8
 * @copyright 2015 Jared King
9
 * @license MIT
10
 */
11
namespace Pulsar\Services;
12
13
use Pulsar\Model;
14
use Pulsar\Validator;
15
16
class ModelDriver
17
{
18
    /**
19
     * @var Pulsar\Driver\DriverInterface
20
     */
21
    private $driver;
22
23
    public function __construct($app)
24
    {
25
        // make the app available to models
26
        Model::inject($app);
27
28
        // set up the model driver
29
        $config = $app['config'];
30
        $class = $config->get('models.driver');
31
        $this->driver = new $class($app);
32
        Model::setDriver($this->driver);
33
34
        // used for password hasing
35
        Validator::configure(['salt' => $config->get('app.salt')]);
36
    }
37
38
    public function __invoke()
39
    {
40
        return $this->driver;
41
    }
42
}
43