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

ModelAdapter::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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