| @@ 82-97 (lines=16) @@ | ||
| 79 | * |
|
| 80 | * @return Providers\ProviderInterface |
|
| 81 | */ |
|
| 82 | public function __get($key) |
|
| 83 | { |
|
| 84 | $key = strtolower($key); |
|
| 85 | ||
| 86 | if (isset($this->providers[$key])) { |
|
| 87 | return $this->providers[$key]; |
|
| 88 | } |
|
| 89 | ||
| 90 | $class = 'SocialLinks\\Providers\\'.ucfirst($key); |
|
| 91 | ||
| 92 | if (class_exists($class)) { |
|
| 93 | return $this->providers[$key] = new $class($this); |
|
| 94 | } |
|
| 95 | ||
| 96 | throw new \Exception("The provider $key does not exists"); |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|
| 100 | * Magic method to instantiate and return metas in lazy mode. |
|
| @@ 109-124 (lines=16) @@ | ||
| 106 | * |
|
| 107 | * @return Metas\MetaInterface |
|
| 108 | */ |
|
| 109 | public function __call($key, $arguments) |
|
| 110 | { |
|
| 111 | $key = strtolower($key); |
|
| 112 | ||
| 113 | if (isset($this->metas[$key])) { |
|
| 114 | return $this->metas[$key]; |
|
| 115 | } |
|
| 116 | ||
| 117 | $class = 'SocialLinks\\Metas\\'.ucfirst($key); |
|
| 118 | ||
| 119 | if (class_exists($class)) { |
|
| 120 | return $this->metas[$key] = new $class($this); |
|
| 121 | } |
|
| 122 | ||
| 123 | throw new \Exception("The meta $key does not exists"); |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * Preload the counter. |
|