| Total Complexity | 14 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | trait ServiceInstances |
||
| 6 | { |
||
| 7 | public $instances = []; |
||
| 8 | |||
| 9 | public function getInstance($binding) |
||
| 10 | { |
||
| 11 | if (is_null($instance = $this->getFromInstanceCache($binding))) { |
||
| 12 | $instance = app('firewall.'.$binding); |
||
| 13 | } |
||
| 14 | |||
| 15 | $this->setInstance($binding, $instance); |
||
| 16 | |||
| 17 | return $instance; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getFromInstanceCache($binding) |
||
| 21 | { |
||
| 22 | if (isset($this->instances[$binding])) { |
||
| 23 | return $this->instances[$binding]; |
||
| 24 | } |
||
| 25 | |||
| 26 | return null; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function setInstance($binding, $instance) |
||
| 30 | { |
||
| 31 | $this->instances[$binding] = $instance; |
||
| 32 | } |
||
| 33 | |||
| 34 | public function countries() |
||
| 35 | { |
||
| 36 | return $this->getInstance('countries'); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function ipList() |
||
| 40 | { |
||
| 41 | return $this->getInstance('iplist'); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function messages() |
||
| 45 | { |
||
| 46 | return $this->getInstance('messages'); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function cache() |
||
| 52 | } |
||
| 53 | |||
| 54 | public function config() |
||
| 55 | { |
||
| 56 | return $this->getInstance('config'); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function fileSystem() |
||
| 60 | { |
||
| 61 | return $this->getInstance('filesystem'); |
||
| 62 | } |
||
| 63 | |||
| 64 | public function geoIp() |
||
| 65 | { |
||
| 66 | return $this->getInstance('geoip'); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function ipAddress() |
||
| 70 | { |
||
| 71 | return $this->getInstance('ipaddress'); |
||
| 72 | } |
||
| 73 | |||
| 74 | public function dataRepository() |
||
| 77 | } |
||
| 78 | } |
||
| 79 |