aboutsummaryrefslogtreecommitdiff
path: root/classes/helpers/CinisisHttpHelper.php
blob: e262b3a0ab0db4878547f09e39ca4763fb1c5239 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

/**
 * Http helper for test scripts.
 */
class CinisisHttpHelper {
  /**
   * Get an argument.
   *
   * @param $name
   *   Argument name.
   *
   * @param $default
   *   Default value.
   *
   * @return
   *   Argument value.
   */
  static function get_arg($name, $default = 1) {
    // Get the query parameter.
    if (isset($_GET[$name]) && ! empty($_GET[$name])) {
      $arg = $_GET[$name];
    }
    else {
      $arg = $default;
    }  

    return $arg;
  }

  /**
   * Get a numeric argument.
   *
   * @param $name
   *   Argument name.
   *
   * @return
   *   Argument value.
   */
  static function get_numeric_arg($name) {
    return (int) self::get_arg($name, 1);
  }

  /**
   * Get a string argument.
   *
   * @param $name
   *   Argument name.
   *
   * @return
   *   Argument value.
   */
  static function get_textual_arg($name) {
    return (string) self::get_arg($name, 'a');
  }
}