Code Duplication    Length = 24-25 lines in 2 locations

src/DI/TInjectable.php 2 locations

@@ 41-65 (lines=25) @@
38
     * @return object as the service requested.
39
     * @throws \Exception
40
     */
41
    public function __get($service)
42
    {
43
        if (!$this->di) {
44
            throw new \Exception(
45
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to get
46
                message, code a property from $this->di, but $this->di is not set. Did you
47
                forget to call setDI()?'
48
            );
49
        }
50
51
        try {
52
53
            $this->$service = $this->di->get($service);
54
            return $this->$service;
55
56
        } catch (\Exception $e) {
57
            throw new \Exception(
58
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to get
59
                a property (service) "' . $service . '" from $this->di, but the service is not
60
                set in $this->di. Did you misspell the service you are trying to reach or did
61
                you forget to load it into the $di container?'
62
                . $e->getMessage()
63
            );
64
        }
65
    }
66
67
68
    /**
@@ 78-101 (lines=24) @@
75
     * @return object as the service requested.
76
     * @throws \Exception
77
     */
78
    public function __call($service, $arguments = [])
79
    {
80
        if (!$this->di) {
81
            throw new \Exception(
82
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to call a
83
                method in $this->di, but $this->di is not set. Did you forget to call setDI()?'
84
            );
85
        }
86
87
        try {
88
89
            $this->$service = $this->di->get($service);
90
            return $this->$service;
91
92
        } catch (\Exception $e) {
93
            throw new \Exception(
94
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to get a
95
                method (service) "' . $service . '" from $this->di, but the service is not set
96
                in $this->di. Did you misspell the service you are trying to reach or did you
97
                forget to load it into the $di container? '
98
                . $e->getMessage()
99
            );
100
        }
101
    }
102
}
103