Overview

Packages

  • tipy

Classes

  • Tipy
  • TipyApp
  • TipyCli
  • TipyCliSession
  • TipyConfig
  • TipyController
  • TipyCookie
  • TipyDAO
  • TipyEnv
  • TipyFlash
  • TipyInflector
  • TipyInput
  • TipyIOWrapper
  • TipyLogger
  • TipyMailer
  • TipyModel
  • TipyOutput
  • TipyRequest
  • TipySession
  • TipyTestCase
  • TipyTestRunner
  • TipyView

Exceptions

  • AssertionFailedException
  • CompileErrorException
  • CompileWarningException
  • CoreErrorException
  • CoreWarningException
  • DeprecatedException
  • NoMethodException
  • NoticeException
  • ParseException
  • RecoverableErrorException
  • StrictException
  • TipyDaoException
  • TipyException
  • TipyModelException
  • TipyRollbackException
  • TipyValidationException
  • UserDeprecatedException
  • UserErrorException
  • UserNoticeException
  • UserWarningException
  • WarningException
  • Overview
  • Package
  • Class
  • Deprecated
  • Todo
 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: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 
<?php
/**
 * TipyIOWrapper
 *
 * @package tipy
 */

/**
 * Base class to wrap input/output superglobals for sanitation/validation
 *
 * For example if you want extra XSS protection on input or output
 * you may use controller's executeBefore() or executeAfter() hooks:
 *
 * <code>
 * class MyController extends TipyController {
 *     public function executeAfter() {
 *         foreach ($this->out->getAll() as $key => $value) {
 *             $this->out->set($key, htmlspecialchars($value));
 *         }
 *     }
 * }
 * </code>
 */
class TipyIOWrapper {

    /**
     * This array represents superglobal arrays like $_GET, $_POST, etc...
     */
    private $map;

    /**
     * Construct empty TipyIOWrapper instance
     */
    public function __construct() {
        $this->map = [];
    }

    /**
     * Specify array to wrap in TipyIOWrapper
     *
     * This array should be a hash with string keys.
     * This may be superglobal array like $_GET, $_POST, etc...
     *
     * @param array $map
     */
    public function bind(array $map) {
        $this->map = $map;
    }

    /**
     * Return value from internal hash by key name
     *
     * If key does not exist return defaultValue
     *
     * @param string $key
     * @param mixed $defaultValue
     * @return mixed
     */
    public function get($key, $defaultValue = null) {
        return array_key_exists($key, $this->map) ? $this->map[$key] : $defaultValue;
    }

    /**
     *
     * @param string $key
     * @param mixed $value
     */
    public function set($key, $value) {
        $this->map[$key] = $value;
    }

    /**
     * Return all data from internal map
     */
    public function getAll() {
        return $this->map;
    }

    /**
     * Clear all data in internal map
     */
    public function clear() {
        $this->map = [];
    }
}
tipy API documentation generated by ApiGen