Completed
Push — master ( f38213...c5a8cb )
by Jared
02:23
created

ModelAdapter   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 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
wmc 2
lcom 0
cbo 2
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 ModelAdapter
17
{
18
    /**
19
     * @var Pulsar\Adapter\AdapterInterface
20
     */
21
    private $adapter;
22
23
    public function __construct($app)
24
    {
25
        // make the locale available to models
26
        Model::setLocale($app['locale']);
27
28
        // set up the model adapter
29
        $config = $app['config'];
30
        $class = $config->get('models.adapter');
31
        $this->adapter = new $class($app);
32
        Model::setAdapter($this->adapter);
33
34
        // used for password hasing
35
        Validator::configure(['salt' => $config->get('app.salt')]);
36
    }
37
38
    public function __invoke()
39
    {
40
        return $this->adapter;
41
    }
42
}
43