factory() public static method

Takes an array and wraps it inside an object. If $strict is not set to FALSE, the original array will be destroyed, and the data can only be accessed via the object's accessor methods
public static factory ( array &$source, string $conf_file = null, string $conf_section = null, boolean $strict = true ) : Cage
$source array
$conf_file string
$conf_section string
$strict boolean
return Cage
Beispiel #1
0
 /**
  * Returns the $_FILES data wrapped in an Cage object
  *
  * This utilizes a singleton pattern to get around scoping issues
  *
  * @param string $config_file
  * @param boolean $strict whether or not to nullify the superglobal array
  * @return Cage
  */
 public static function makeFilesCage($config_file = null, $strict = true)
 {
     /**
      * @staticvar $_instance
      */
     static $_instance;
     if (!isset($_instance)) {
         $_instance = Cage::factory($_FILES, $config_file, '_FILES', $strict);
     }
     $GLOBALS['HTTP_POST_FILES'] = null;
     return $_instance;
 }
Beispiel #2
0
 /**
  */
 public function testNoTagsOrSpecial()
 {
     $input = array('foo' => '    <SCRIPT<strong>>alert(\'foobar\');<</strong>/SCRIPT>');
     $cage = Cage::factory($input);
     $expect = '&#21;&#21;&#21;&#21;&#21;&#21;&#22; &#22; &#22; &#22; alert(&#38;#39;foobar&#38;#39;);';
     $this->assertSame($expect, $cage->noTagsOrSpecial('foo'));
 }