예제 #1
0
 /**
  * Constructs a new parameter based on the given information.
  * 
  * @param string $name the new parameter's name
  * @param string $type the new parameter's return type
  * @param array:string $constraints the new parameter's constraint(s)
  */
 public function __construct($name, $type, $constraints)
 {
     parent::__construct($name);
     Validator::validateString($type, 'type');
     Validator::validateStringArray($constraints, 'constraints');
     $this->name = $name;
     $this->type = $type;
     $this->constraints = $constraints;
 }
예제 #2
0
 /**
  * Constructs a new serialisation-based persistence store in the given directory.
  * 
  * @param string $dir the name of the directory to use
  * @throws InvalidArgumentException the directory name is invalid
  */
 public function __construct($dir)
 {
     Validator::validateString($dir, 'directory');
     if (!is_dir($dir)) {
         throw new InvalidArgumentException('The given directory store is not a directory: ' . $dir);
     }
     $this->dir = $dir;
     $this->lockFile = $dir . '/' . self::LOCK_FILE;
 }
예제 #3
0
 /**
  * Constructs a new method based on the given information.
  * 
  * @param string $name the new method's name
  * @param string $returnType the new method's return type
  * @param array $parameters the new method's parameters
  * @param array $constraints the new method's constraint(s)
  */
 public function __construct($name, $returnType, $parameters, $constraints)
 {
     parent::__construct($name);
     Validator::validateString($returnType, 'return type');
     Validator::validateTypedArray($parameters, 'Shawware\\CodingChallenge\\Model\\Parameter', 'parameters');
     Validator::validateStringArray($constraints, 'constraints');
     $this->name = $name;
     $this->returnType = $returnType;
     $this->parameters = $parameters;
     $this->constraints = $constraints;
 }
예제 #4
0
 /**
  * Constructs a new test case.
  * 
  * @param boolean $isExample whether this test case is an example
  * @param array $inputs the inputs for this test case
  * @param mixed $expectedOutput the expected output
  * @param string $explanation optional explanation of the expected output
  */
 public function __construct($isExample, $inputs, $expectedOutput, $explanation = '')
 {
     parent::__construct('test case');
     Validator::validateBoolean($isExample, 'is example');
     Validator::validateArray($inputs, 'inputs');
     Validator::validateNotNull($expectedOutput, 'expected output');
     Validator::validateString($explanation, 'explanation', true);
     $this->isExample = $isExample;
     $this->inputs = $inputs;
     $this->expectedOutput = $expectedOutput;
     $this->explanation = $explanation;
 }
예제 #5
0
 /**
  * Updates this entity's name.
  * 
  * @param string $name the new name
  */
 public final function updateName($name)
 {
     Validator::validateString($name, 'name');
     $this->name = $name;
 }