Skip to content

Instantly share code, notes, and snippets.

@andreconghau
Created August 30, 2017 08:37
Show Gist options
  • Save andreconghau/8007b34adef8b2a3bd8f0c316b99c896 to your computer and use it in GitHub Desktop.
Save andreconghau/8007b34adef8b2a3bd8f0c316b99c896 to your computer and use it in GitHub Desktop.
Class config with Singleton parttern
<?php
class Configuration {
private static $instance;
private function __construct($configuration) {/* */}
public static function getInstance() {
if (self::$instance === null) {
self::$instance = new Configuration();
}
return self::$instance;
}
public function get($key) {/* */}
public function getAll() {/* */}
}
$singleton = Configuration::getInstance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment