getFormatter() public method

public getFormatter ( $formatter ) : Callable
return Callable
Esempio n. 1
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testGetFormatterThrowsExceptionOnIncorrectFormatter()
 {
     $generator = new Generator();
     $provider = new FooProvider();
     $generator->addProvider($provider);
     $generator->getFormatter('barFormatter');
 }
Esempio n. 2
0
 /**
  * Get a faker formatter
  *
  * @param $schema
  * @param null $property
  * @return Callable
  * @throws InvalidArgumentException
  */
 private function getFormatter($schema, $property = null)
 {
     if ($this->provider->hasProperty($schema, 'format')) {
         $format = $this->provider->getProperty($schema, 'format');
         if (array_key_exists($format, self::$map)) {
             $format = self::$map[$format];
         }
         return $this->generator->getFormatter($format);
     }
     if (null !== $property) {
         return $this->generator->getFormatter($property);
     }
     throw new InvalidArgumentException('Formatter could not be found');
 }