<?php

class UrlHelper {
  /**
   * Stores the reference to the Page Helper
   */
  public static $_instance = null;

  public static function getInstance()
  {
    if (is_null(self::$_instance)) {
      self::$_instance = new self();
    }

    return self::$_instance;
  }

  /**
  * Return a URL segment
  * @param  int $segment The URL segment you want
  * @return String          The segment name
  */
  public function getURLSegment($segment)
  {
    $segments = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));

    return (sizeof($segments) > $segment) ? $segments[$segment] : "";
  }
}