PHP Classes

PHP Registry with Singleton Trait: Set and get registry values using singleton trait

Recommend this page to a friend!
  Info   View files Example   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 141 This week: 1All time: 9,190 This week: 571Up
Version License PHP version Categories
falcraft-registry 3.0MIT/X Consortium ...5PHP 5, Data types, Design Patterns, T...
Description 

Author

This class can set and get registry values using singleton trait.

It implements a registry of values that acts like an associative arrays of key value pairs.

The class uses a singleton trait to prevent that more than one instance of the class exists in a given moment.

Picture of Asher Wolfstein
  Performance   Level  
Name: Asher Wolfstein <contact>
Classes: 15 packages by
Country: United States United States
Age: 40
All time rank: 1122164 in United States United States
Week rank: 50 Up7 in United States United States Up
Innovation award
Innovation award
Nominee: 5x

Example

<?php

require_once('../../Patterns/Registry.php');

use
Falcraft\Patterns;

echo
"Falcraft\\Patterns\\Registry.php Test\n";
echo
"-----------------------------------\n\n";

echo
"Instantiating Singleton -> ";

$success = true;

$testRegistryInstance = null;

try {
   
$testRegistryInstance = Patterns\Registry::instantiate();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Add Registry Slot: exampleKey => exampleValue -> ";

$success = true;

try {
   
$testRegistryInstance->set('exampleKey', 'exampleValue');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n\n";
} else {
    echo
"Failure...\n\n";
}

var_dump($testRegistryInstance);

echo
"Instantiate Again Into Alternate Local Variable -> ";

$success = true;

$testRegistryInstanceTwo = null;

try {
   
$testRegistryInstanceTwo = Patterns\Registry::instantiate();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

var_dump($testRegistryInstanceTwo);


  Files folder image Files  
File Role Description
Files folder imageFalcraft (3 directories)
Files folder imagesrc (1 directory)
Files folder imagetests (1 directory)
Accessible without login Plain text file composer.json Conf. Composer File
Accessible without login Plain text file LICENSE.txt Lic. License (MIT)
Accessible without login Plain text file phpunit.xml Conf. Unit Testing
Accessible without login Plain text file README.txt Doc. README

  Files folder image Files  /  Falcraft  
File Role Description
Files folder imageData (1 directory)
Files folder imageexamples (1 directory)
Files folder imagePatterns (1 file, 1 directory)

  Files folder image Files  /  Falcraft  /  Data  
File Role Description
Files folder imageTypes (1 file)

  Files folder image Files  /  Falcraft  /  Data  /  Types  
File Role Description
  Plain text file Null.php Class An auxiliary data structure

  Files folder image Files  /  Falcraft  /  examples  
File Role Description
Files folder imagePatterns (1 file)

  Files folder image Files  /  Falcraft  /  examples  /  Patterns  
File Role Description
  Accessible without login Plain text file Registry.php Example Example Script

  Files folder image Files  /  Falcraft  /  Patterns  
File Role Description
Files folder imageException (2 files)
  Plain text file Registry.php Class The main class

  Files folder image Files  /  Falcraft  /  Patterns  /  Exception  
File Role Description
  Plain text file ExceptionInterface.php Class The local exception interface
  Plain text file RangeException.php Class Local range exception class

  Files folder image Files  /  src  
File Role Description
Files folder imagePhabstractic (2 directories)

  Files folder image Files  /  src  /  Phabstractic  
File Role Description
Files folder imageData (1 directory)
Files folder imagePatterns (1 file, 1 directory)

  Files folder image Files  /  src  /  Phabstractic  /  Data  
File Role Description
Files folder imageTypes (1 file)

  Files folder image Files  /  src  /  Phabstractic  /  Data  /  Types  
File Role Description
  Accessible without login Plain text file None.php Aux. None Data Type

  Files folder image Files  /  src  /  Phabstractic  /  Patterns  
File Role Description
Files folder imageException (2 files)
  Plain text file Registry.php Class Main Class

  Files folder image Files  /  src  /  Phabstractic  /  Patterns  /  Exception  
File Role Description
  Plain text file ExceptionInterface.php Class Local Exception Class
  Plain text file RangeException.php Class Local Exception Class

  Files folder image Files  /  tests  
File Role Description
Files folder imagePhabstractic (2 directories)

  Files folder image Files  /  tests  /  Phabstractic  
File Role Description
Files folder imageData (1 directory)
Files folder imagePatterns (1 file)

  Files folder image Files  /  tests  /  Phabstractic  /  Data  
File Role Description
Files folder imageTypes (1 file)

  Files folder image Files  /  tests  /  Phabstractic  /  Data  /  Types  
File Role Description
  Accessible without login Plain text file None.php Test unit testing

  Files folder image Files  /  tests  /  Phabstractic  /  Patterns  
File Role Description
  Accessible without login Plain text file Registry.php Test unit testing

Downloadfalcraft-registry-2016-07-10.zip 13KB
Downloadfalcraft-registry-2016-07-10.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Singleton Trait Download .zip .tar.gz Required to make registry a singleton Required
 Version Control Unique User Downloads Download Rankings  
 0%
Total:141
This week:1
All time:9,190
This week:571Up