/** * Test that the Stapler class can build a single instance of * the Validator class. * * @test * @return void */ public function it_should_be_able_to_create_a_singleton_validator_instance() { $validator1 = Stapler::getValidatorInstance(); $validator2 = Stapler::getValidatorInstance(); $this->assertInstanceOf('Codesleeve\\Stapler\\Validator', $validator1); $this->assertSame($validator1, $validator2); }
/** * Create a new attachment object. * * @param string $name * @param array $options * @return \Codesleeve\Stapler\Attachment */ public static function create($name, array $options) { $options = static::mergeOptions($options); Stapler::getValidatorInstance()->validateOptions($options); list($config, $interpolator, $resizer) = static::buildDependencies($name, $options); $attachment = new AttachmentObject($config, $interpolator, $resizer); $storageDriver = StorageFactory::create($attachment); $attachment->setStorageDriver($storageDriver); return $attachment; }