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