Permalink
Browse files

Code cleanup

PAssed php-cs-fixer, fixed commas
  • Loading branch information...
1 parent 379494f commit 7c2682780204fc1da1e0e0319c8ae88aeee95a3f @fzaninotto committed Dec 10, 2012
Showing with 5,946 additions and 15,115 deletions.
  1. +44 −44 src/Faker/Documentor.php
  2. +34 −34 src/Faker/Factory.php
  3. +57 −56 src/Faker/Generator.php
  4. +52 −52 src/Faker/Guesser/Name.php
  5. +40 −38 src/Faker/ORM/Doctrine/ColumnTypeGuesser.php
  6. +93 −93 src/Faker/ORM/Doctrine/EntityPopulator.php
  7. +52 −52 src/Faker/ORM/Doctrine/Populator.php
  8. +26 −26 src/Faker/ORM/Mandango/ColumnTypeGuesser.php
  9. +100 −100 src/Faker/ORM/Mandango/EntityPopulator.php
  10. +44 −44 src/Faker/ORM/Mandango/Populator.php
  11. +62 −59 src/Faker/ORM/Propel/ColumnTypeGuesser.php
  12. +157 −154 src/Faker/ORM/Propel/EntityPopulator.php
  13. +68 −67 src/Faker/ORM/Propel/Populator.php
  14. +114 −110 src/Faker/Provider/Address.php
  15. +144 −142 src/Faker/Provider/Base.php
  16. +20 −19 src/Faker/Provider/Company.php
  17. +173 −173 src/Faker/Provider/DateTime.php
  18. +130 −126 src/Faker/Provider/Internet.php
  19. +207 −204 src/Faker/Provider/Lorem.php
  20. +55 −55 src/Faker/Provider/Miscellaneous.php
  21. +33 −32 src/Faker/Provider/Person.php
  22. +8 −8 src/Faker/Provider/PhoneNumber.php
  23. +23 −22 src/Faker/Provider/bg_BG/Internet.php
  24. +114 −114 src/Faker/Provider/bg_BG/Person.php
  25. +13 −13 src/Faker/Provider/bg_BG/PhoneNumber.php
  26. +28 −28 src/Faker/Provider/cs_CZ/Internet.php
  27. +92 −90 src/Faker/Provider/cs_CZ/Person.php
  28. +7 −7 src/Faker/Provider/cs_CZ/PhoneNumber.php
  29. +100 −100 src/Faker/Provider/da_DK/Address.php
  30. +1 −0 src/Faker/Provider/da_DK/Internet.php
  31. +113 −113 src/Faker/Provider/da_DK/Person.php
  32. +82 −82 src/Faker/Provider/de_AT/Address.php
  33. +183 −183 src/Faker/Provider/de_AT/Person.php
  34. +62 −62 src/Faker/Provider/de_DE/Address.php
  35. +7 −7 src/Faker/Provider/de_DE/Company.php
  36. +39 −38 src/Faker/Provider/de_DE/Internet.php
  37. +185 −185 src/Faker/Provider/de_DE/Person.php
  38. +13 −13 src/Faker/Provider/de_DE/PhoneNumber.php
  39. +77 −77 src/Faker/Provider/en_GB/Address.php
  40. +3 −3 src/Faker/Provider/en_GB/Internet.php
  41. +12 −12 src/Faker/Provider/en_GB/PhoneNumber.php
  42. +86 −86 src/Faker/Provider/en_US/Address.php
  43. +50 −50 src/Faker/Provider/en_US/Company.php
  44. +80 −80 src/Faker/Provider/en_US/Person.php
  45. +26 −26 src/Faker/Provider/en_US/PhoneNumber.php
  46. +84 −84 src/Faker/Provider/es_AR/Address.php
  47. +52 −52 src/Faker/Provider/es_AR/Company.php
  48. +75 −75 src/Faker/Provider/es_AR/Person.php
  49. +35 −35 src/Faker/Provider/es_AR/PhoneNumber.php
  50. +90 −90 src/Faker/Provider/es_ES/Address.php
  51. +63 −63 src/Faker/Provider/es_ES/Company.php
  52. +38 −38 src/Faker/Provider/es_ES/Person.php
  53. +9 −9 src/Faker/Provider/es_ES/PhoneNumber.php
  54. +75 −75 src/Faker/Provider/fi_FI/Address.php
  55. +50 −50 src/Faker/Provider/fi_FI/Company.php
  56. +3 −3 src/Faker/Provider/fi_FI/Internet.php
  57. +64 −64 src/Faker/Provider/fi_FI/Person.php
  58. +13 −13 src/Faker/Provider/fi_FI/PhoneNumber.php
  59. +119 −119 src/Faker/Provider/fr_FR/Address.php
  60. +151 −151 src/Faker/Provider/fr_FR/Company.php
  61. +39 −38 src/Faker/Provider/fr_FR/Internet.php
  62. +25 −25 src/Faker/Provider/fr_FR/Person.php
  63. +37 −37 src/Faker/Provider/fr_FR/PhoneNumber.php
  64. +86 −86 src/Faker/Provider/it_IT/Address.php
  65. +51 −51 src/Faker/Provider/it_IT/Company.php
  66. +69 −69 src/Faker/Provider/it_IT/Person.php
  67. +9 −9 src/Faker/Provider/it_IT/PhoneNumber.php
  68. +31 −31 src/Faker/Provider/pl_PL/Internet.php
  69. +43 −43 src/Faker/Provider/pl_PL/Person.php
  70. +7 −7 src/Faker/Provider/pl_PL/PhoneNumber.php
  71. +125 −125 src/Faker/Provider/pt_BR/Address.php
  72. +52 −52 src/Faker/Provider/pt_BR/Company.php
  73. +89 −89 src/Faker/Provider/pt_BR/Person.php
  74. +24 −24 src/Faker/Provider/pt_BR/PhoneNumber.php
  75. +144 −143 src/Faker/Provider/ru_RU/Address.php
  76. +21 −20 src/Faker/Provider/ru_RU/Internet.php
  77. +84 −84 src/Faker/Provider/ru_RU/Person.php
  78. +7 −7 src/Faker/Provider/ru_RU/PhoneNumber.php
  79. +332 −332 src/Faker/Provider/sk_SK/Address.php
  80. +50 −50 src/Faker/Provider/sk_SK/Company.php
  81. +28 −28 src/Faker/Provider/sk_SK/Internet.php
  82. +146 −144 src/Faker/Provider/sk_SK/Person.php
  83. +8 −8 src/Faker/Provider/sk_SK/PhoneNumber.php
  84. +3 −284 src/Faker/Provider/sr_Cyrl_RS/Address.php
  85. +2 −2,789 src/Faker/Provider/sr_Cyrl_RS/Person.php
  86. +3 −284 src/Faker/Provider/sr_Latn_RS/Address.php
  87. +2 −2,789 src/Faker/Provider/sr_Latn_RS/Person.php
  88. +3 −284 src/Faker/Provider/sr_RS/Address.php
  89. +2 −2,789 src/Faker/Provider/sr_RS/Person.php
  90. +16 −14 src/autoload.php
  91. +112 −112 test/Faker/GeneratorTest.php
  92. +102 −102 test/Faker/Provider/BaseTest.php
  93. +16 −16 test/Faker/Provider/LocalizationTest.php
  94. +92 −93 test/Faker/Provider/LoremTest.php
  95. +14 −14 test/Faker/Provider/PersonTest.php
  96. +0 −1 test/Faker/Provider/UserAgentTest.php
  97. +40 −40 test/Faker/Provider/fr_FR/CompanyTest.php
  98. +1 −1 test/documentor.php
  99. +1 −1 test/test.php
View
@@ -4,51 +4,51 @@
class Documentor
{
- protected $generator;
+ protected $generator;
- public function __construct($generator)
- {
- $this->generator = $generator;
- }
+ public function __construct($generator)
+ {
+ $this->generator = $generator;
+ }
- public function getFormatters()
- {
- $formatters = array();
- $providers = array_reverse($this->generator->getProviders());
- $providers[]= new \Faker\Provider\Base($this->generator);
- foreach ($providers as $provider) {
- $providerClass = get_class($provider);
- $formatters[$providerClass] = array();
- $refl = new \ReflectionObject($provider);
- foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflmethod) {
- if ($reflmethod->getDeclaringClass()->getName() == 'Faker\Provider\Base' && $providerClass != 'Faker\Provider\Base') {
- continue;
- }
- $methodName = $reflmethod->name;
- if ($reflmethod->isConstructor()) {
- continue;
- }
- $parameters = array();
- foreach ($reflmethod->getParameters() as $reflparameter) {
- $parameter = '$'. $reflparameter->getName();
- if ($reflparameter->isDefaultValueAvailable()) {
- $parameter .= ' = ' . var_export($reflparameter->getDefaultValue(), true);
- }
- $parameters []= $parameter;
- }
- $parameters = $parameters ? '('. join(', ', $parameters) . ')' : '';
- $example = $this->generator->format($methodName);
- if (is_array($example)) {
- $example = "array('". join("', '", $example) . "')";
- } elseif($example instanceof \DateTime) {
- $example = "DateTime('" . $example->format('Y-m-d H:i:s') . "')";
- } else {
- $example = var_export($example, true);
- }
- $formatters[$providerClass][$methodName . $parameters] = $example;
- }
- }
+ public function getFormatters()
+ {
+ $formatters = array();
+ $providers = array_reverse($this->generator->getProviders());
+ $providers[]= new \Faker\Provider\Base($this->generator);
+ foreach ($providers as $provider) {
+ $providerClass = get_class($provider);
+ $formatters[$providerClass] = array();
+ $refl = new \ReflectionObject($provider);
+ foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflmethod) {
+ if ($reflmethod->getDeclaringClass()->getName() == 'Faker\Provider\Base' && $providerClass != 'Faker\Provider\Base') {
+ continue;
+ }
+ $methodName = $reflmethod->name;
+ if ($reflmethod->isConstructor()) {
+ continue;
+ }
+ $parameters = array();
+ foreach ($reflmethod->getParameters() as $reflparameter) {
+ $parameter = '$'. $reflparameter->getName();
+ if ($reflparameter->isDefaultValueAvailable()) {
+ $parameter .= ' = ' . var_export($reflparameter->getDefaultValue(), true);
+ }
+ $parameters []= $parameter;
+ }
+ $parameters = $parameters ? '('. join(', ', $parameters) . ')' : '';
+ $example = $this->generator->format($methodName);
+ if (is_array($example)) {
+ $example = "array('". join("', '", $example) . "')";
+ } elseif ($example instanceof \DateTime) {
+ $example = "DateTime('" . $example->format('Y-m-d H:i:s') . "')";
+ } else {
+ $example = var_export($example, true);
+ }
+ $formatters[$providerClass][$methodName . $parameters] = $example;
+ }
+ }
- return $formatters;
- }
+ return $formatters;
+ }
}
View
@@ -4,43 +4,43 @@
class Factory
{
- const DEFAULT_LOCALE = 'en_US';
+ const DEFAULT_LOCALE = 'en_US';
- protected static $defaultProviders = array('Person', 'Address', 'PhoneNumber', 'Company', 'Lorem', 'Internet', 'DateTime', 'Miscellaneous', 'UserAgent');
+ protected static $defaultProviders = array('Person', 'Address', 'PhoneNumber', 'Company', 'Lorem', 'Internet', 'DateTime', 'Miscellaneous', 'UserAgent');
- public static function create($locale = self::DEFAULT_LOCALE)
- {
- $generator = new Generator();
- foreach (static::$defaultProviders as $provider) {
- $providerClassName = self::getProviderClassname($provider, $locale);
- $generator->addProvider(new $providerClassName($generator));
- }
+ public static function create($locale = self::DEFAULT_LOCALE)
+ {
+ $generator = new Generator();
+ foreach (static::$defaultProviders as $provider) {
+ $providerClassName = self::getProviderClassname($provider, $locale);
+ $generator->addProvider(new $providerClassName($generator));
+ }
- return $generator;
- }
+ return $generator;
+ }
- protected static function getProviderClassname($provider, $locale = '')
- {
- if ($providerClass = self::findProviderClassname($provider, $locale)) {
- return $providerClass;
- }
- // fallback to default locale
- if ($providerClass = self::findProviderClassname($provider, static::DEFAULT_LOCALE)) {
- return $providerClass;
- }
- // fallback to no locale
- $providerClass = self::findProviderClassname($provider);
- if (class_exists($providerClass)) {
- return $providerClass;
- }
- throw new \InvalidArgumentException(sprintf('Unable to find provider "%s" with locale "%s"', $provider, $locale));
- }
+ protected static function getProviderClassname($provider, $locale = '')
+ {
+ if ($providerClass = self::findProviderClassname($provider, $locale)) {
+ return $providerClass;
+ }
+ // fallback to default locale
+ if ($providerClass = self::findProviderClassname($provider, static::DEFAULT_LOCALE)) {
+ return $providerClass;
+ }
+ // fallback to no locale
+ $providerClass = self::findProviderClassname($provider);
+ if (class_exists($providerClass)) {
+ return $providerClass;
+ }
+ throw new \InvalidArgumentException(sprintf('Unable to find provider "%s" with locale "%s"', $provider, $locale));
+ }
- protected static function findProviderClassname($provider, $locale = '')
- {
- $providerClass = 'Faker\\' . ($locale ? sprintf('Provider\%s\%s', $locale, $provider) : sprintf('Provider\%s', $provider));
- if (class_exists($providerClass, true)) {
- return $providerClass;
- }
- }
+ protected static function findProviderClassname($provider, $locale = '')
+ {
+ $providerClass = 'Faker\\' . ($locale ? sprintf('Provider\%s\%s', $locale, $provider) : sprintf('Provider\%s', $provider));
+ if (class_exists($providerClass, true)) {
+ return $providerClass;
+ }
+ }
}
View
@@ -4,69 +4,70 @@
class Generator
{
- protected $providers = array();
- protected $formatters = array();
+ protected $providers = array();
+ protected $formatters = array();
- public function addProvider($provider)
- {
- array_unshift($this->providers, $provider);
- }
+ public function addProvider($provider)
+ {
+ array_unshift($this->providers, $provider);
+ }
- public function getProviders()
- {
- return $this->providers;
- }
+ public function getProviders()
+ {
+ return $this->providers;
+ }
- public function seed($seed = null)
- {
- mt_srand($seed);
- }
+ public function seed($seed = null)
+ {
+ mt_srand($seed);
+ }
- public function format($formatter, $arguments = array())
- {
- return call_user_func_array($this->getFormatter($formatter), $arguments);
- }
+ public function format($formatter, $arguments = array())
+ {
+ return call_user_func_array($this->getFormatter($formatter), $arguments);
+ }
- /**
- * @return Callable
- */
- public function getFormatter($formatter)
- {
- if (isset($this->formatters[$formatter])) {
- return $this->formatters[$formatter];
- }
- foreach ($this->providers as $provider) {
- if (method_exists($provider, $formatter)) {
- $this->formatters[$formatter] = array($provider, $formatter);
- return $this->formatters[$formatter];
- }
- }
- throw new \InvalidArgumentException(sprintf('Unknown formatter "%s"', $formatter));
- }
+ /**
+ * @return Callable
+ */
+ public function getFormatter($formatter)
+ {
+ if (isset($this->formatters[$formatter])) {
+ return $this->formatters[$formatter];
+ }
+ foreach ($this->providers as $provider) {
+ if (method_exists($provider, $formatter)) {
+ $this->formatters[$formatter] = array($provider, $formatter);
- /**
- * Replaces tokens ('{{ tokenName }}') with the result from the token method call
- *
- * @param string $string String that needs to bet parsed
- * @return string
- */
- public function parse($string)
- {
- return preg_replace_callback('/\{\{\s?(\w+)\s?\}\}/', array($this, 'callFormatWithMatches'), $string);
- }
+ return $this->formatters[$formatter];
+ }
+ }
+ throw new \InvalidArgumentException(sprintf('Unknown formatter "%s"', $formatter));
+ }
- protected function callFormatWithMatches($matches)
- {
- return $this->format($matches[1]);
- }
+ /**
+ * Replaces tokens ('{{ tokenName }}') with the result from the token method call
+ *
+ * @param string $string String that needs to bet parsed
+ * @return string
+ */
+ public function parse($string)
+ {
+ return preg_replace_callback('/\{\{\s?(\w+)\s?\}\}/', array($this, 'callFormatWithMatches'), $string);
+ }
- public function __get($attribute)
- {
- return $this->format($attribute);
- }
+ protected function callFormatWithMatches($matches)
+ {
+ return $this->format($matches[1]);
+ }
- public function __call($method, $attributes)
- {
- return $this->format($method, $attributes);
- }
+ public function __get($attribute)
+ {
+ return $this->format($attribute);
+ }
+
+ public function __call($method, $attributes)
+ {
+ return $this->format($method, $attributes);
+ }
}
Oops, something went wrong.

0 comments on commit 7c26827

Please sign in to comment.