Code Duplication    Length = 22-23 lines in 2 locations

src/DI/TInjectable.php 2 locations

@@ 41-63 (lines=23) @@
38
     *
39
     * @return class as the service requested.
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
            $this->$service = $this->di->get($service);
53
            return $this->$service;
54
        } catch (\Exception $e) {
55
            throw new \Exception(
56
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to get
57
                a property (service) "' . $service . '" from $this->di, but the service is not
58
                set in $this->di. Did you misspell the service you are trying to reach or did
59
                you forget to load it into the $di container?'
60
                . $e->getMessage()
61
            );
62
        }
63
    }
64
65
66
@@ 76-97 (lines=22) @@
73
     *
74
     * @return class as the service requested.
75
     */
76
    public function __call($service, $arguments = [])
77
    {
78
        if (!$this->di) {
79
            throw new \Exception(
80
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to call a
81
                method in $this->di, but $this->di is not set. Did you forget to call setDI()?'
82
            );
83
        }
84
85
        try {
86
            $this->$service = $this->di->get($service);
87
            return $this->$service;
88
        } catch (\Exception $e) {
89
            throw new \Exception(
90
                'In trait TInjectable used by class ' . __CLASS__ . '. You are trying to get a
91
                method (service) "' . $service . '" from $this->di, but the service is not set
92
                in $this->di. Did you misspell the service you are trying to reach or did you
93
                forget to load it into the $di container? '
94
                . $e->getMessage()
95
            );
96
        }
97
    }
98
}
99