Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
GautierDele authored and StyleCIBot committed Oct 29, 2024
1 parent 85be35f commit fb1d751
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
18 changes: 10 additions & 8 deletions src/Extensions/TextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TextExtension extends Extension
use HasLocale;

/**
* Text in format => Paragraphs => Sentences => Words
* Text in format => Paragraphs => Sentences => Words.
*
* @var array|array[]
*/
Expand All @@ -20,37 +20,37 @@ class TextExtension extends Extension
['Curabitur', 'et', 'vestibulum', 'nulla.'],
['Donec', 'placerat', 'tempor', 'arcu,', 'in', 'viverra', 'sapien', 'laoreet', 'eu.'],
['Sed', 'vitae', 'ligula', 'eget', 'mauris', 'malesuada', 'pretium', 'in', 'at', 'lorem.'],
['Integer', 'condimentum', 'urna', 'at', 'lacus', 'fermentum,', 'nec', 'sagittis', 'purus', 'venenatis.']
['Integer', 'condimentum', 'urna', 'at', 'lacus', 'fermentum,', 'nec', 'sagittis', 'purus', 'venenatis.'],
],
[
['Nunc', 'at', 'ligula', 'id', 'nisl', 'varius', 'egestas.'],
['Suspendisse', 'eget', 'nulla', 'dapibus,', 'efficitur', 'purus', 'a,', 'congue', 'quam.'],
['Donec', 'sagittis', 'interdum', 'libero', 'non', 'ornare.'],
['Nam', 'non', 'massa', 'lacus.'],
['Etiam', 'fermentum', 'neque', 'ut', 'est', 'porttitor,', 'ut', 'tincidunt', 'risus', 'suscipit.'],
['Nam', 'id', 'nisi', 'eget', 'lorem', 'vehicula', 'eleifend.']
['Nam', 'id', 'nisi', 'eget', 'lorem', 'vehicula', 'eleifend.'],
],
[
['Quisque', 'accumsan', 'nisl', 'ut', 'quam', 'pretium,', 'eget', 'lacinia', 'arcu', 'lobortis.'],
['Nam', 'dapibus', 'justo', 'nec', 'nibh', 'dapibus,', 'ac', 'varius', 'velit', 'varius.'],
['Nulla', 'facilisi.'],
['Praesent', 'volutpat', 'suscipit', 'nibh,', 'eget', 'congue', 'ante', 'ornare', 'a.'],
['Nam', 'aliquet', 'risus', 'eget', 'leo', 'gravida', 'scelerisque.']
['Nam', 'aliquet', 'risus', 'eget', 'leo', 'gravida', 'scelerisque.'],
],
[
['Aenean', 'accumsan', 'leo', 'at', 'odio', 'vestibulum,', 'non', 'fermentum', 'nisl', 'varius.'],
['Suspendisse', 'in', 'quam', 'sed', 'ligula', 'convallis', 'sodales.'],
['Mauris', 'consequat', 'risus', 'sit', 'amet', 'libero', 'iaculis,', 'quis', 'volutpat', 'eros', 'scelerisque.'],
['Pellentesque', 'habitants', 'morbi', 'tristique', 'senectus', 'et', 'netus', 'et', 'malesuada', 'fames', 'ac', 'turpis', 'egestas.']
['Pellentesque', 'habitants', 'morbi', 'tristique', 'senectus', 'et', 'netus', 'et', 'malesuada', 'fames', 'ac', 'turpis', 'egestas.'],
],
[
['Donec', 'ultricies', 'euismod', 'libero,', 'vel', 'scelerisque', 'enim', 'condimentum', 'ut.'],
['Fusce', 'varius', 'urna', 'ac', 'ipsum', 'ultricies,', 'vel', 'elementum', 'turpis', 'dictum.'],
['Proin', 'nec', 'ante', 'at', 'erat', 'pharetra', 'interdum.'],
['Etiam', 'nec', 'ligula', 'felis.'],
['Curabitur', 'sit', 'amet', 'varius', 'nisi,', 'in', 'sagittis', 'turpis.'],
['Sed', 'eget', 'ex', 'quis', 'risus', 'varius', 'pharetra', 'in', 'a', 'felis.']
]
['Sed', 'eget', 'ex', 'quis', 'risus', 'varius', 'pharetra', 'in', 'a', 'felis.'],
],
];

protected array $flattenedWords;
Expand Down Expand Up @@ -85,6 +85,7 @@ public function wordsAsArray(int $wordsCount = 3): array
public function words(int $wordsCount = 3): string
{
$words = $this->wordsAsArray($wordsCount);

// Remove any uppercase / comma / dots
return strtolower(preg_replace('/[.,]/', '', implode(' ', $words)));
}
Expand All @@ -94,11 +95,11 @@ public function sentencesAsArray(int $sentencesCount = 3): array
return $this->pickArrayRandomElements($this->flattenedSentences(), $sentencesCount);
}


public function sentences(int $sentencesCount = 3): string
{
$sentences = $this->sentencesAsArray($sentencesCount);
$sentences = array_map(function ($sentence) { return implode(' ', $sentence); }, $sentences);

return implode(' ', $sentences);
}

Expand All @@ -111,6 +112,7 @@ public function paragraphs(int $paragraphsCount = 3): string
{
$paragraphs = $this->paragraphsAsArray($paragraphsCount);
$paragraphs = array_map(function ($sentences) { return implode(' ', array_merge(...$sentences)); }, $paragraphs);

return implode(PHP_EOL, $paragraphs);
}
}
2 changes: 1 addition & 1 deletion src/FakerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Xefi\Faker\Extensions\FinancialExtension;
use Xefi\Faker\Extensions\HashExtension;
use Xefi\Faker\Extensions\InternetExtension;
use Xefi\Faker\Extensions\TextExtension;
use Xefi\Faker\Extensions\NumbersExtension;
use Xefi\Faker\Extensions\PersonExtension;
use Xefi\Faker\Extensions\StringsExtension;
use Xefi\Faker\Extensions\TextExtension;
use Xefi\Faker\Providers\Provider;

class FakerServiceProvider extends Provider
Expand Down
7 changes: 2 additions & 5 deletions tests/Unit/Extensions/TextExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function testWordsWithDefaultValue(): void
}
}


public static function wordsProvider()
{
return [
Expand All @@ -43,7 +42,7 @@ public static function wordsProvider()
[7],
[8],
[9],
[10]
[10],
];
}

Expand Down Expand Up @@ -73,7 +72,6 @@ public function testSentencesWithDefaultValue(): void
}
}


public static function sentencesProvider()
{
return [
Expand All @@ -86,7 +84,7 @@ public static function sentencesProvider()
[7],
[8],
[9],
[10]
[10],
];
}

Expand Down Expand Up @@ -115,7 +113,6 @@ public function testParagraphsWithDefaultValue(): void
}
}


public static function paragraphsProvider()
{
return [
Expand Down

0 comments on commit fb1d751

Please sign in to comment.