Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Small tweaks #1526

Merged
merged 4 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Faker/ORM/Spot/EntityPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ public function guessColumnFormatters(Generator $generator)
if (empty($records)) {
return null;
}
$id = $records[mt_rand(0, count($records) - 1)]['id'];

return $id;
return $records[mt_rand(0, count($records) - 1)]['id'];
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/HtmlLorem.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function addRandomSubTree(\DOMElement $root, $maxDepth, $maxWidth)
$this->addRandomAttribute($sibling);
$this->addRandomSubTree($sibling, mt_rand(0, $maxDepth), $maxWidth);
}
};
}
return $root;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/at_AT/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Payment extends \Faker\Provider\Payment
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "AT U" : "ATU";
$prefix = $spacedNationalPrefix ? "AT U" : "ATU";

return sprintf("%s%d", $prefix, self::randomNumber(8, true));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/bg_BG/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function bankAccountNumber($prefix = '', $countryCode = 'BG', $len
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "BG " : "BG";
$prefix = $spacedNationalPrefix ? "BG " : "BG";

return sprintf(
"%s%d%d",
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/fr_BE/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function bankAccountNumber($prefix = '', $countryCode = 'BE', $len
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "BE " : "BE";
$prefix = $spacedNationalPrefix ? "BE " : "BE";

return sprintf("%s0%d", $prefix, self::randomNumber(9, true));
}
Expand Down
6 changes: 3 additions & 3 deletions src/Faker/Provider/lt_LT/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ public function personalIdentityNumber($gender = 'male', \DateTime $birthdate =
$birthdate = \Faker\Provider\DateTime::dateTimeThisCentury();
}

$genderNumber = ($gender == 'male') ? (int) 1 : (int) 0;
$genderNumber = ($gender == 'male') ? 1 : 0;
$firstNumber = (int) floor($birthdate->format('Y') / 100) * 2 - 34 - $genderNumber;

$datePart = $birthdate->format('ymd');
$randomDigits = (string) ( ! $randomNumber || strlen($randomNumber < 3)) ? static::numerify('###') : substr($randomNumber, 0, 3);
$randomDigits = (string) ( ! $randomNumber || strlen($randomNumber) < 3) ? static::numerify('###') : substr($randomNumber, 0, 3);
$partOfPerosnalCode = $firstNumber . $datePart . $randomDigits;

$sum = self::calculateSum($partOfPerosnalCode, 1);
Expand All @@ -318,7 +318,7 @@ public function personalIdentityNumber($gender = 'male', \DateTime $birthdate =
}

$sum = self::calculateSum($partOfPerosnalCode, 2);
$liekana = (int) $sum % 11;
$liekana = $sum % 11;

$lastNumber = ($liekana !== 10) ? $liekana : 0;
return $firstNumber . $datePart . $randomDigits . $lastNumber;
Expand Down
4 changes: 2 additions & 2 deletions src/Faker/Provider/ms_MY/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ public static function myKadNumber($gender = null, $hyphen = false)
$dd = DateTime::dayOfMonth();

// place of birth (1-59 except 17-20)
while (in_array(($pb = mt_rand(1, 59)), array(17, 18, 19, 20))) {
};
while (in_array($pb = mt_rand(1, 59), array(17, 18, 19, 20))) {
}

// random number
$nnn = mt_rand(0, 999);
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/nl_BE/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function bankAccountNumber($prefix = '', $countryCode = 'BE', $len
*/
public static function vat($spacedNationalPrefix = true)
{
$prefix = ($spacedNationalPrefix) ? "BE " : "BE";
$prefix = $spacedNationalPrefix ? "BE " : "BE";

return sprintf("%s0%d", $prefix, self::randomNumber(9, true));
}
Expand Down
3 changes: 1 addition & 2 deletions src/Faker/Provider/ro_RO/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
public function phoneNumber()
{
$type = static::randomElement(array_keys(static::$normalFormats));
$number = static::numerify(static::randomElement(static::$normalFormats[$type]));

return $number;
return static::numerify(static::randomElement(static::$normalFormats[$type]));
}

public static function tollFreePhoneNumber()
Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/ColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testSafeHexColor()

public function testRgbColorAsArray()
{
$this->assertEquals(3, count(Color::rgbColorAsArray()));
$this->assertCount(3, Color::rgbColorAsArray());
}

public function testRgbColor()
Expand Down
1 change: 0 additions & 1 deletion test/Faker/Provider/el_GR/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down
9 changes: 0 additions & 9 deletions test/Faker/Provider/en_UG/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,20 @@ public function setUp()
$this->faker = $faker;
}

/**
* @test
*/
public function testCityName()
{
$city = $this->faker->cityName();
$this->assertNotEmpty($city);
$this->assertInternalType('string', $city);
}

/**
* @test
*/
public function testDistrict()
{
$district = $this->faker->district();
$this->assertNotEmpty($district);
$this->assertInternalType('string', $district);
}

/**
* @test
*/
public function testRegion()
{
$region = $this->faker->region();
Expand Down
4 changes: 2 additions & 2 deletions test/Faker/Provider/en_US/PhoneNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testPhoneNumber()
}

// 10 digits
$this->assertEquals(10, count($digits));
$this->assertCount(10, $digits);

// Last two digits of area code cannot be identical
$this->assertNotEquals($digits[1], $digits[2]);
Expand Down Expand Up @@ -68,7 +68,7 @@ public function testTollFreePhoneNumber()
}

// 10 digits
$this->assertEquals(10, count($digits));
$this->assertCount(10, $digits);

$areaCode = $digits[0] . $digits[1] . $digits[2];
$this->assertContains($areaCode, array('800', '822', '833', '844', '855', '866', '877', '888', '880', '887', '889'));
Expand Down
3 changes: 0 additions & 3 deletions test/Faker/Provider/fr_FR/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function setUp()
$this->faker = $faker;
}

/**
* @test
*/
public function testSecondaryAddress()
{
$secondaryAdress = $this->faker->secondaryAddress();
Expand Down
1 change: 0 additions & 1 deletion test/Faker/Provider/fr_FR/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down
1 change: 0 additions & 1 deletion test/Faker/Provider/ka_GE/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down
1 change: 0 additions & 1 deletion test/Faker/Provider/kk_KZ/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down
1 change: 0 additions & 1 deletion test/Faker/Provider/ko_KR/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/ro_RO/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected function isValidCnp($cnp)
foreach (range(0, 11) as $digit) {
$checksum += (int)substr($cnp, $digit, 1) * (int)substr($checkNumber, $digit, 1);
}
$checksum = $checksum % 11;
$checksum %= 11;
$checksum = $checksum == 10 ? 1 : $checksum;

if ($checksum == substr($cnp, -1)) {
Expand Down
1 change: 0 additions & 1 deletion test/Faker/Provider/ru_RU/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/zh_TW/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public function testPersonalIdentityNumber()
}

// Validate
$this->assertEquals(0, ($total % 10));
$this->assertEquals(0, $total % 10);
}
}
4 changes: 0 additions & 4 deletions test/Faker/Provider/zh_TW/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function getMethod($name) {
return $method;
}

/** @test */
function testItShouldExplodeTheStringToArray()
{
$this->assertSame(
Expand All @@ -35,7 +34,6 @@ function testItShouldExplodeTheStringToArray()
);
}

/** @test */
function testItShouldReturnTheStringLength()
{
$this->assertContains(
Expand All @@ -44,7 +42,6 @@ function testItShouldReturnTheStringLength()
);
}

/** @test */
function testItShouldReturnTheCharacterIsValidStartOrNot()
{
$this->assertTrue($this->getMethod('validStart')->invokeArgs(null, array('中')));
Expand All @@ -58,7 +55,6 @@ function testItShouldReturnTheCharacterIsValidStartOrNot()
$this->assertFalse($this->getMethod('validStart')->invokeArgs(null, array('!')));
}

/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
Expand Down