Issues (22)

Manager/GeodisManager.php (3 issues)

1
<?php
2
3
namespace GeodisBundle\Manager;
4
5
use Doctrine\ORM\EntityManager;
0 ignored issues
show
The type Doctrine\ORM\EntityManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use GeodisBundle\DAO\Connection;
7
use GeodisBundle\DAO\Exception\ApiException;
8
9
abstract class GeodisManager
10
{
11
    protected $list = [];
12
    protected $model;
13
    protected $config;
14
    protected $em;
15
16
    public function __construct(EntityManager $em)
17
    {
18
        $this->em = $em;
19
    }
20
21
    public function setConfig($config)
22
    {
23
        $this->config = $config;
24
    }
25
26
    public function init()
27
    {
28
        try {
29
            Connection::setConfig($this->config, $this->em);
30
        } catch (ApiException $e) {
31
            throw new Exception("Can't initiate connection: ", $e->getCode());
0 ignored issues
show
The type GeodisBundle\Manager\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
32
        }
33
    }
34
35
    /**
36
     * @return object
37
     */
38
    public function getModel($name)
39
    {
40
        try {
41
            $classname = $cname = 'GeodisBundle\\Model\\'.$name;
0 ignored issues
show
The assignment to $cname is dead and can be removed.
Loading history...
42
43
            $this->model = new $classname();
44
45
            return $this;
46
        } catch (ApiException $e) {
47
            throw new ApiException("Model doesn't existe : ", $e->getStatusCode());
48
        }
49
    }
50
}
51