GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LaravelContainer   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 7 2
A has() 0 13 4
1
<?php
2
3
namespace LBHurtado\Missive\Container;
4
5
use ReflectionException;
6
use Psr\Container\ContainerInterface;
7
use Illuminate\Contracts\Container\Container;
8
use Psr\Container\NotFoundExceptionInterface;
9
use Psr\Container\ContainerExceptionInterface;
10
use Illuminate\Container\EntryNotFoundException;
11
12
class LaravelContainer implements ContainerInterface
13
{
14
    /** @var Container */
15
    protected $container;
16
17
    public function __construct(Container $container)
18
    {
19
        $this->container = $container;
20
    }
21
22
    /**
23
     * Finds an entry of the container by its identifier and returns it.
24
     *
25
     * @param string $id Identifier of the entry to look for.
26
     *
27
     * @throws NotFoundExceptionInterface  No entry was found for **this** identifier.
28
     * @throws ContainerExceptionInterface Error while retrieving the entry.
29
     *
30
     * @return mixed Entry.
31
     */
32
    public function get($id)
33
    {
34
        if ($this->has($id)) {
35
            return $this->container->make($id);
36
        }
37
        throw new EntryNotFoundException;
38
    }
39
40
    /**
41
     * Returns true if the container can return an entry for the given identifier.
42
     * Returns false otherwise.
43
     *
44
     * `has($id)` returning true does not mean that `get($id)` will not throw an exception.
45
     * It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
46
     *
47
     * @param string $id Identifier of the entry to look for.
48
     *
49
     * @return bool
50
     */
51
    public function has($id)
52
    {
53
        if ($this->container->bound($id) || $this->container->resolved($id)) {
54
            return true;
55
        }
56
        try {
57
            $this->container->make($id);
58
59
            return true;
60
        } catch (ReflectionException $e) {
61
            return false;
62
        }
63
    }
64
}
65