Skip to content

Commit e9584cf

Browse files
Reduce code smell (#32)
* Reduce code smell * Reduce code smell
1 parent 4e892a0 commit e9584cf

File tree

9 files changed

+16
-20
lines changed

9 files changed

+16
-20
lines changed

src/Faker/Factory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ protected static function getProviderClassname($provider, $locale = '')
4949
/**
5050
* @param string $provider
5151
* @param string $locale
52-
* @return string
52+
* @return string|null
5353
*/
5454
protected static function findProviderClassname($provider, $locale = '')
5555
{
5656
$providerClass = 'Faker\\' . ($locale ? sprintf('Provider\%s\%s', $locale, $provider) : sprintf('Provider\%s', $provider));
5757
if (class_exists($providerClass, true)) {
5858
return $providerClass;
5959
}
60+
61+
return null;
6062
}
6163
}

src/Faker/Guesser/Name.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(\Faker\Generator $generator)
1919
/**
2020
* @param string $name
2121
* @param int|null $size Length of field, if known
22-
* @return callable
22+
* @return callable|null
2323
*/
2424
public function guessFormat($name, $size = null)
2525
{
@@ -152,5 +152,7 @@ public function guessFormat($name, $size = null)
152152
return $generator->text;
153153
};
154154
}
155+
156+
return null;
155157
}
156158
}

src/Faker/ORM/Mandango/EntityPopulator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public function guessColumnFormatters(\Faker\Generator $generator, Mandango $man
8585
if (isset($insertedEntities[$referenceClass])) {
8686
return Base::randomElement($insertedEntities[$referenceClass]);
8787
}
88+
89+
return null;
8890
};
8991
}
9092

src/Faker/Provider/Base.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ public static function randomKey($array = array())
248248
return null;
249249
}
250250
$keys = array_keys($array);
251-
$key = $keys[mt_rand(0, count($keys) - 1)];
252-
253-
return $key;
251+
return $keys[mt_rand(0, count($keys) - 1)];
254252
}
255253

256254
/**

src/Faker/Provider/Uuid.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function uuid()
3838
$tHi |= (3 << 12);
3939

4040
// cast to string
41-
$uuid = sprintf(
41+
return sprintf(
4242
'%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x',
4343
$tLo,
4444
$tMi,
@@ -52,7 +52,5 @@ public static function uuid()
5252
$byte[14],
5353
$byte[15]
5454
);
55-
56-
return $uuid;
5755
}
5856
}

src/Faker/Provider/fr_CH/Person.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ public static function avs13()
108108

109109
$checksum = \Faker\Calculator\Ean::checksum(implode($p));
110110

111-
$avs = sprintf("%s.%s.%s.%s%s", $p[0], $p[1], $p[2], $p[3], $checksum);
112-
113-
return $avs;
111+
return sprintf("%s.%s.%s.%s%s", $p[0], $p[1], $p[2], $p[3], $checksum);
114112
}
115113
}

src/Faker/Provider/kk_KZ/Person.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ private static function getCenturyByYear($year)
189189
} elseif ($year >= 1800) {
190190
return self::CENTURY_19TH;
191191
}
192+
193+
return null;
192194
}
193195

194196
/**

src/Faker/Provider/ro_RO/PhoneNumber.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,11 @@ public function phoneNumber()
5252

5353
public static function tollFreePhoneNumber()
5454
{
55-
$number = static::numerify(static::randomElement(static::$specialFormats['toll-free']));
56-
57-
return $number;
55+
return static::numerify(static::randomElement(static::$specialFormats['toll-free']));
5856
}
5957

6058
public static function premiumRatePhoneNumber()
6159
{
62-
$number = static::numerify(static::randomElement(static::$specialFormats['premium-rate']));
63-
64-
return $number;
60+
return static::numerify(static::randomElement(static::$specialFormats['premium-rate']));
6561
}
6662
}

src/Faker/Provider/zh_TW/Person.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ public function personalIdentityNumber($gender = null)
194194
$checkSumDigit = 0;
195195
}
196196

197-
$id = $birthPlace . $genderCode . $randomNumberCode . $checkSumDigit;
198-
199-
return $id;
197+
return $birthPlace . $genderCode . $randomNumberCode . $checkSumDigit;
200198
}
201199
}

0 commit comments

Comments
 (0)