get() public method

Gets the value associated to the key, or null if the key is not found.
public get ( $key ) : mixed
return mixed
Example #1
0
 /**
  * Cleans the html of any none-html information.
  *
  * @param string $str
  * @return string
  */
 protected function clean($str)
 {
     if ($this->options->get('cleanupInput') != true) {
         // skip entire cleanup step
         return $str;
     }
     // remove white space before closing tags
     $str = mb_eregi_replace("'\\s+>", "'>", $str);
     $str = mb_eregi_replace('"\\s+>', '">', $str);
     // clean out the \n\r
     $replace = ' ';
     if ($this->options->get('preserveLineBreaks')) {
         $replace = '
';
     }
     $str = str_replace(["\r\n", "\r", "\n"], $replace, $str);
     // strip the doctype
     $str = mb_eregi_replace("<!doctype(.*?)>", '', $str);
     // strip out comments
     $str = mb_eregi_replace("<!--(.*?)-->", '', $str);
     // strip out cdata
     $str = mb_eregi_replace("<!\\[CDATA\\[(.*?)\\]\\]>", '', $str);
     // strip out <script> tags
     if ($this->options->get('removeScripts') == true) {
         $str = mb_eregi_replace("<\\s*script[^>]*[^/]>(.*?)<\\s*/\\s*script\\s*>", '', $str);
         $str = mb_eregi_replace("<\\s*script\\s*>(.*?)<\\s*/\\s*script\\s*>", '', $str);
     }
     // strip out <style> tags
     if ($this->options->get('removeStyles') == true) {
         $str = mb_eregi_replace("<\\s*style[^>]*[^/]>(.*?)<\\s*/\\s*style\\s*>", '', $str);
         $str = mb_eregi_replace("<\\s*style\\s*>(.*?)<\\s*/\\s*style\\s*>", '', $str);
     }
     // strip out server side scripts
     $str = mb_eregi_replace("(<\\?)(.*?)(\\?>)", '', $str);
     // strip smarty scripts
     $str = mb_eregi_replace("(\\{\\w)(.*?)(\\})", '', $str);
     return $str;
 }
Example #2
0
 public function testAddingOver()
 {
     $options = new Options();
     $options->setOptions(['test' => false])->setOptions(['test' => true, 'whitespaceTextNode' => false]);
     $this->assertFalse($options->get('whitespaceTextNode'));
 }
 public function testGettingNoOption()
 {
     $options = new Options();
     $this->assertEquals(null, $options->get('doesnotexist'));
 }