Skip to content

Instantly share code, notes, and snippets.

@avdg
Created April 2, 2011 19:44
Show Gist options
  • Select an option

  • Save avdg/899811 to your computer and use it in GitHub Desktop.

Select an option

Save avdg/899811 to your computer and use it in GitHub Desktop.

Revisions

  1. avdg revised this gist Apr 2, 2011. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,14 @@
    <?php
    static function getCache($p_mOptions = null) {

    if (is_array($p_mOptions)) {
    $options = $p_mOptions;
    } else {
    static function getCache($p_mOptions = null)
    {
    if (!is_array($p_mOptions)) {
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    if (is_string($p_mOptions)) {
    $options['handler'] = $p_mOptions;
    }
    $p_mOptions = $options;
    }

    return $options;
    return $p_mOptions;
    }
  2. @salathe salathe revised this gist Apr 2, 2011. 1 changed file with 9 additions and 18 deletions.
    27 changes: 9 additions & 18 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,15 @@
    <?php
    static function getCache($p_mOptions = null) {

    switch(gettype($p_mOptions)) {

    case 'array':
    return new PPI_Cache($p_mOptions);
    break;

    case 'string':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    if (is_array($p_mOptions)) {
    $options = $p_mOptions;
    } else {
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    if (is_string($p_mOptions)) {
    $options['handler'] = $p_mOptions;
    return new PPI_Cache($options);
    break;

    case 'null':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    return new PPI_Cache($options);
    break

    }
    }

    return $options;
    }
  3. @dragoonis dragoonis revised this gist Apr 2, 2011. 1 changed file with 18 additions and 18 deletions.
    36 changes: 18 additions & 18 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,24 @@
    <?php
    static function getCache($p_mOptions = null) {
    static function getCache($p_mOptions = null) {

    switch(gettype($p_mOptions)) {
    switch(gettype($p_mOptions)) {

    case 'array':
    return new PPI_Cache($p_mOptions);
    break;
    case 'array':
    return new PPI_Cache($p_mOptions);
    break;

    case 'string':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    $options['handler'] = $p_mOptions;
    return new PPI_Cache($options);
    break;
    case 'string':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    $options['handler'] = $p_mOptions;
    return new PPI_Cache($options);
    break;

    case 'null':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    return new PPI_Cache($options);
    break
    case 'null':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    return new PPI_Cache($options);
    break

    }
    }
    }
    }
  4. @dragoonis dragoonis revised this gist Apr 2, 2011. 1 changed file with 19 additions and 19 deletions.
    38 changes: 19 additions & 19 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,24 @@
    <?php
    /**
    * Get the cache object
    *
    * @param null|string|array $p_mOptions The information to get a different cache object
    * @return PPI_Cache
    */
    static function getCache($p_mOptions = null) {

    if(is_array($p_mOptions)) {
    return new PPI_Cache($p_mOptions);
    }
    switch(gettype($p_mOptions)) {

    $options = array();
    // Lets use the defaults from the config file as no special parameters were needed.
    if($p_mOptions === null || ($bIsString = is_string($p_mOptions))) {
    $config = self::getConfig();
    $options = !empty($config->cache->handler) ? $config->cache->toArray() : array();
    if(isset($bIsString) && $bIsString === true) {
    $options['handler'] = $p_mOptions;
    }
    }
    return new PPI_Cache($options);
    case 'array':
    return new PPI_Cache($p_mOptions);
    break;

    case 'string':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    $options['handler'] = $p_mOptions;
    return new PPI_Cache($options);
    break;

    case 'null':
    $config = self::getConfig();
    $options = isset($config->cache) ? $config->cache->toArray() : array();
    return new PPI_Cache($options);
    break

    }
    }
  5. @dragoonis dragoonis revised this gist Apr 2, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /**
    * Get the cache object
    *
  6. @dragoonis dragoonis renamed this gist Apr 2, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @dragoonis dragoonis created this gist Apr 2, 2011.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    /**
    * Get the cache object
    *
    * @param null|string|array $p_mOptions The information to get a different cache object
    * @return PPI_Cache
    */
    static function getCache($p_mOptions = null) {

    if(is_array($p_mOptions)) {
    return new PPI_Cache($p_mOptions);
    }

    $options = array();
    // Lets use the defaults from the config file as no special parameters were needed.
    if($p_mOptions === null || ($bIsString = is_string($p_mOptions))) {
    $config = self::getConfig();
    $options = !empty($config->cache->handler) ? $config->cache->toArray() : array();
    if(isset($bIsString) && $bIsString === true) {
    $options['handler'] = $p_mOptions;
    }
    }
    return new PPI_Cache($options);
    }