<commit_before><?php
/**
 * Manages loading of classes.
 *
 * @copyright Copyright (c) 2012 bne1.
 * @author <NAME> [au] <<EMAIL>>
 * @license http://www.opensource.org/licenses/mit-license.php
 *
 * @package Sutra
 * @link http://www.sutralib.com/
 *
 * @version 1.2
 */
class sLoader extends fLoader {
  const best  = 'sLoader::best';
  const eagar = 'sLoader::eagar';
  const lazy  = 'sLoader::lazy';

  /**
   * Path where Sutra is installed.
   *
   * @var string
   */
  private static $path = '';

  /**
   * All the Sutra classes.
   *
   * @var array
   */
  private static $classes = array(
    'sArray',
    'sAuthorization',
    'sCache',
    'sCore',
    'sGrammar',
    'sHTML',
    'sHTTPRequest',
    'sImage',
    'sJSONP',
    'sNumber',
    'sObject',
    'sORMJSON',
    'sProcess',
    'sProcessException',
    'sRequest',
    'sResponse',
    'sTemplate',
    'sTimestamp',
  );

  /**
   * Override best() method.
   *
   * @return void
   * @see sLoader::eagar()
   */
  public static function best() {
    if (self::hasOpcodeCache()) {
      return sLoader::eagar();
    }

    self::lazy();
  }

  /**
   * Creates constructor functions. This makes it possible to write:
   *
   * <code>new sProcess('node myscript')->execute();</code>
   *
   * @return void
   */
  private static function createConstructorFunctions() {
    if (function_exists('sImage')) {
      return;
    }

    function sImage($file_path, $skip_checks = FALSE) {
      return new sImage($file_path, $skip_checks);
    }

    // Limited signature support
    function sProcess($name) {
      return new sProcess($name);
    }

    function sTimestamp($datetime, $timezone = NULL) {
      return new sTimestamp($datetime, $timezone);
    }
  }

  /**
   * Override eager() method to load Sutra classes after Flourish's.
   *
   * @return void
   */
  public static function eagar() {
    parent::eager();

    self::setPath();
    self::createConstructorFunctions();

    foreach (self::$classes as $class) {
      require self::$path.$class.'.php';
    }
  }

  /**
   * Determines where Sutra is installed.<commit_msg>Update constructor functions<commit_after><?php
/**
 * Manages loading of classes.
 *
 * @copyright Copyright (c) 2012 bne1.
 * @author <NAME> [au] <<EMAIL>>
 * @license http://www.opensource.org/licenses/mit-license.php
 *
 * @package Sutra
 * @link http://www.sutralib.com/
 *
 * @version 1.2
 */
class sLoader extends fLoader {
  const best  = 'sLoader::best';
  const eagar = 'sLoader::eagar';
  const lazy  = 'sLoader::lazy';

  /**
   * Path where Sutra is installed.
   *
   * @var string
   */
  private static $path = '';

  /**
   * All the Sutra classes.
   *
   * @var array
   */
  private static $classes = array(
    'sArray',
    'sAuthorization',
    'sCache',
    'sCore',
    'sGrammar',
    'sHTML',
    'sHTTPRequest',
    'sImage',
    'sJSONP',
    'sNumber',
    'sObject',
    'sORMJSON',
    'sProcess',
    'sProcessException',
    'sRequest',
    'sResponse',
    'sTemplate',
    'sTimestamp',
  );

  /**
   * Override best() method.
   *
   * @return void
   * @see sLoader::eagar()
   */
  public static function best() {
    if (self::hasOpcodeCache()) {
      return sLoader::eagar();
    }

    self::lazy();
  }

  /**
   * Creates constructor functions. This makes it possible to write:
   *
   * <code>new sProcess('node myscript')->execute();</code>
   *
   * @return void
   */
  private static function createConstructorFunctions() {
    if (function_exists('sHTTPRequest')) {
      return;
    }

    function sHTTPRequest($url, $method = 'GET', $timeout = NULL) {
      return new sHTTPRequest($url, $method, $timeout);
    }

    function sImage($file_path, $skip_checks = FALSE) {
      return new sImage($file_path, $skip_checks);
    }

    function sNumber($value, $scale = NULL) {
      return new sNumber($value, $scale);
    }

    function sObject(array $arg) {
      return new sObject($arg);
    }

    // Limited signature support
    function sProcess($name) {
      return new sProcess($name);
    }

    function sTimestamp($datetime, $timezone = NULL) {
      return new sTimestamp($datetime, $timezone);
    }
  }

  /**
   * Override eager() method to load Sutra classes after Flourish's.
   *
   * @return void
   */
  public static function eagar() {
    parent::eager();

    self::setPath();
    self::createConstructorFunctions();

    foreach (self::$classes as $class) {
      require self::$path.$class.'.php';
    }
  }

  /**
   * Determines where Sutra is installed.
{'fraction_non_alphanumeric': 0.15499451152579583, 'fraction_numerical': 0.0030735455543358945, 'mean_word_length': 2.6448, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '69153', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1464, 'n_words': 352}