コード例 #1
0
 /**
  * Creates a new object builder.
  *
  * If a type constraint is provided, then the builder will only create
  * objects from classes of that type.
  * If a requested instance does not meet the type requirements, then
  * an exception will be thrown.
  *
  * @param string|array(string)|null $typeConstraints A single type or a list of required types.
  * @throws InvalidArgumentException If provided type constraint is not valid.
  */
 public function __construct($typeConstraints = array())
 {
     $typeConstraints = $this->toList($typeConstraints);
     $this->typeInspector = new Mol_Util_TypeInspector();
     $this->typeInspector->assertTypes($typeConstraints);
     $this->typeConstraints = $typeConstraints;
 }
コード例 #2
0
 /**
  * Checks if assertTypes() accepts a list of type names.
  */
 public function testAssertTypesAcceptsListOfValidTypes()
 {
     $this->setExpectedException(null);
     $this->inspector->assertTypes(array('ArrayObject', 'ArrayAccess'));
 }