| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 | 
							- <?php
 - 
 - /*
 -  This program is free software: you can redistribute it and/or modify
 -  it under the terms of the GNU General Public License as published by
 -  the Free Software Foundation, either version 3 of the License, or
 -  (at your option) any later version.
 -  
 -  This program is distributed in the hope that it will be useful,
 -  but WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 -  GNU General Public License for more details.
 - 
 -  You should have received a copy of the GNU General Public License
 -  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -  
 -  */
 -  
 - //require 'Yay/Expectations.php';
 - //require 'Yay/Matchers/OptionalMatcher.php';
 - //require 'Yay/Matchers/AnyMatcher.php';
 - //require 'Yay/Matchers/IdenticalMatcher.php';
 - //require 'Yay/Matchers/EqualMatcher.php';
 - //require 'Yay/Matchers/PatternMatcher.php';
 - //require 'Yay/Matchers/ReferenceMatcher.php';
 - //require 'Yay/Matchers/BoundsMatcher.php';
 - //require 'Yay/Actions/ReturnValueAction.php';
 - //require 'Yay/Actions/ReturnReferenceAction.php';
 - //require 'Yay/Actions/ThrowAction.php';
 - //require 'Yay/Actions/CallbackAction.php';
 - 
 - /**
 -  * A convenience factory class.
 -  * @author Chris Corbyn <chris@w3style.co.uk>
 -  * @package Yay
 -  */
 - class Yay
 - {
 -   
 -   /**
 -    * The classpath used for autoloading.
 -    * @var string
 -    * @access private
 -    */
 -   private static $CLASSPATH = '.';
 -   
 -   // -- Expectations
 -   
 -   /**
 -    * Create a new Expectations builder instance.
 -    * @return Yay_Expectations
 -    */
 -   public static function expectations()
 -   {
 -     return new Yay_Expectations();
 -   }
 -   
 -   // -- Matchers
 -   
 -   /**
 -    * Create a new Optional matcher, optionally wrapping $value.
 -    * @param string $value, optional
 -    * @return Yay_Matchers_OptionalMatcher
 -    */
 -   public static function optional($value = null)
 -   {
 -     return new Yay_Matchers_OptionalMatcher($value);
 -   }
 -   
 -   /**
 -    * Create a new Any matcher, optionally constrained to $type.
 -    * @param string $type, optional
 -    * @return Yay_Matchers_AnyMatcher
 -    */
 -   public static function any($type = null)
 -   {
 -     return new Yay_Matchers_AnyMatcher($type, true);
 -   }
 -   
 -   /**
 -    * Create a negated Any matcher, optionally constrained to $type.
 -    * @param string $type, optional
 -    * @return Yay_Matchers_AnyMatcher
 -    */
 -   public static function none($type = null)
 -   {
 -     return new Yay_Matchers_AnyMatcher($type, false);
 -   }
 -   
 -   /**
 -    * Create a new Identical matcher for $value.
 -    * @param mixed $value
 -    * @return Yay_Matchers_IdenticalMatcher
 -    */
 -   public static function identical($value)
 -   {
 -     return new Yay_Matchers_IdenticalMatcher($value, true);
 -   }
 -   
 -   /**
 -    * Create a negated Identical matcher for $value.
 -    * @param mixed $value
 -    * @return Yay_Matchers_IdenticalMatcher
 -    */
 -   public static function notIdentical($value)
 -   {
 -     return new Yay_Matchers_IdenticalMatcher($value, false);
 -   }
 -   
 -   /**
 -    * Create a new Equal matcher for $value.
 -    * @param mixed $value
 -    * @return Yay_Matchers_EqualMatcher
 -    */
 -   public static function equal($value)
 -   {
 -     return new Yay_Matchers_EqualMatcher($value, true);
 -   }
 -   
 -   /**
 -    * Create a negated Equal matcher for $value.
 -    * @param mixed $value
 -    * @return Yay_Matchers_EqualMatcher
 -    */
 -   public static function notEqual($value)
 -   {
 -     return new Yay_Matchers_EqualMatcher($value, false);
 -   }
 -   
 -   /**
 -    * Create a new Pattern matcher for $pattern.
 -    * @param string $pattern
 -    * @return Yay_Matchers_IsAMatcher
 -    */
 -   public static function pattern($pattern)
 -   {
 -     return new Yay_Matchers_PatternMatcher($pattern, true);
 -   }
 -   
 -   /**
 -    * Create a negated Pattern matcher for $pattern.
 -    * @param string $pattern
 -    * @return Yay_Matchers_IsAMatcher
 -    */
 -   public static function noPattern($pattern)
 -   {
 -     return new Yay_Matchers_PatternMatcher($pattern, false);
 -   }
 -   
 -   /**
 -    * Create a new Reference matcher for $ref.
 -    * @param mixed $ref
 -    * @return Yay_Matchers_ReferenceMatcher
 -    */
 -   public static function reference(&$ref)
 -   {
 -     return new Yay_Matchers_ReferenceMatcher($ref, true);
 -   }
 -   
 -   /**
 -    * Create a negated Reference matcher for $ref.
 -    * @param mixed $ref
 -    * @return Yay_Matchers_ReferenceMatcher
 -    */
 -   public static function noReference(&$ref)
 -   {
 -     return new Yay_Matchers_ReferenceMatcher($ref, false);
 -   }
 -   
 -   /**
 -    * Create a new Bounds matcher for boundaries between $lower and $upper.
 -    * @param mixed $lower
 -    * @param mixed $upper
 -    * @return Yay_Matchers_BoundsMatcher
 -    */
 -   public static function bounds($lower, $upper)
 -   {
 -     return new Yay_Matchers_BoundsMatcher($lower, $upper, true);
 -   }
 -   
 -   /**
 -    * Create a negated Bounds matcher for boundaries outside $lower and $upper.
 -    * @param mixed $lower
 -    * @param mixed $upper
 -    * @return Yay_Matchers_BoundsMatcher
 -    */
 -   public static function outside($lower, $upper)
 -   {
 -     return new Yay_Matchers_BoundsMatcher($lower, $upper, false);
 -   }
 -   
 -   // -- Actions
 -   
 -   /**
 -    * Create a new ReturnValueAction with $value.
 -    * @param mixed $value
 -    * @return Yay_Actions_ReturnValueAction
 -    */
 -   public static function returnValue($value)
 -   {
 -     return new Yay_Actions_ReturnValueAction($value);
 -   }
 -   
 -   /**
 -    * Create a new ReturnReferenceAction with &$ref.
 -    * @param mixed $ref
 -    * @return Yay_Actions_ReturnReferenceAction
 -    */
 -   public static function returnReference(&$ref)
 -   {
 -     return new Yay_Actions_ReturnReferenceAction($ref);
 -   }
 -   
 -   /**
 -    * Create a new ThrowAction with $e.
 -    * @param Exception $ref
 -    * @return Yay_Actions_ThrowAction
 -    */
 -   public static function throwException(Exception $e)
 -   {
 -     return new Yay_Actions_ThrowAction($e);
 -   }
 -   
 -   /**
 -    * Create a new CallbackAction with $callback.
 -    * @param callback $callback
 -    * @return Yay_Actions_CallbackAction
 -    */
 -   public static function call($callback)
 -   {
 -     return new Yay_Actions_CallbackAction($callback);
 -   }
 - 
 -   /**
 -    * Set the classpath for autoloading.
 -    * @param string $path
 -    */
 -   public static function setClassPath($path)
 -   {
 -     self::$CLASSPATH = $path;
 -   }
 - 
 -   /**
 -    * Static autoloader registered in bootstrap file.
 -    * @param string $class
 -    */
 -   public static function autoload($class)
 -   {
 -     if (substr($class, 0, 3) != 'Yay')
 -     {
 -       return;
 -     }
 -     $file = str_replace('_', '/', $class) . '.php';
 -     $path = self::$CLASSPATH . '/' . $file;
 -     if (is_file($path))
 -     {
 -       require_once $path;
 -     }
 -   }
 -   
 - }
 
 
  |