You are here

Get.php in Anti Spam by CleanTalk 9.1.x

Same filename and directory in other branches
  1. 8.4 src/lib/Cleantalk/Common/Variables/Get.php

File

src/lib/Cleantalk/Common/Variables/Get.php
View source
<?php

namespace Cleantalk\Common\Variables;


/**
 * Class Get
 * Safety handler for $_GET
 *
 * @since 3.0
 * @package Cleantalk\Variables
 */
class Get extends SuperGlobalVariables {
  static $instance;

  /**
   * Gets given $_GET variable and save it to memory
   *
   * @param string $name
   * @param bool $do_decode
   *
   * @return mixed|string
   */
  protected function get_variable($name, $do_decode = true) {

    // Return from memory. From $this->variables
    if (isset(static::$instance->variables[$name])) {
      return static::$instance->variables[$name];
    }
    if (function_exists('filter_input')) {
      $value = filter_input(INPUT_GET, $name);
    }
    if (empty($value)) {
      $value = isset($_GET[$name]) ? $_GET[$name] : '';
    }
    $value = $do_decode ? urldecode($value) : $value;

    // Remember for further calls
    static::getInstance()
      ->remember_variable($name, $value);
    return $value;
  }

}

Classes

Namesort descending Description
Get Class Get Safety handler for $_GET