-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #11 use nelmio/alice for data-faking * #11 cs-fixer * #11 implemented generators for providing template data * Update docs/ComponentConfiguration.md Co-authored-by: Benjamin Schultz <[email protected]> * Update tests/Unit/Component/ComponentItemFactoryTest.php Co-authored-by: Benjamin Schultz <[email protected]> * Breakpoint configuration (#18) * add breakpoint config * add disclaimer - added forgotten documentation for breakpoints * Fix typo * Optimize function calls [EA] '$item->$method()' would make more sense here (it's also faster). * Fix route prefix Regarding best practices, the bundle routes must be prefixed with the bundle alias. * Cleanup and optimize code Add strict types and return types where it was missing. * merge update * add class usages * #11 code review changes - added cs-fixer rule for strict types * #11 code review changes --------- Co-authored-by: Benjamin Schultz <[email protected]>
- Loading branch information
1 parent
50f2c96
commit 23adb72
Showing
34 changed files
with
1,021 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Qossmic\TwigDocBundle\Component\Data; | ||
|
||
/** | ||
* Creates fake data to be used in variation display for components. | ||
*/ | ||
class Faker | ||
{ | ||
public function __construct( | ||
/** | ||
* @param GeneratorInterface[] $generators | ||
*/ | ||
private readonly iterable $generators | ||
) { | ||
} | ||
|
||
public function getFakeData(array $params, mixed $variation = []): array | ||
{ | ||
return $this->createFakeData($params, $variation); | ||
} | ||
|
||
private function createFakeData(array $params, mixed $variation): array | ||
{ | ||
$result = []; | ||
|
||
foreach ($params as $name => $type) { | ||
if (\is_array($type)) { | ||
$result[$name] = $this->createFakeData($type, $variation[$name] ?? null); | ||
|
||
continue; | ||
} | ||
|
||
foreach ($this->generators as $generator) { | ||
if (\array_key_exists($name, $result) || !$generator->supports($type)) { | ||
continue; | ||
} | ||
if ($generator->supports($type, $variation)) { | ||
$result[$name] = $generator->generate($type, $variation); | ||
|
||
break; | ||
} | ||
} | ||
|
||
if (!\array_key_exists($name, $result)) { | ||
// set from variation | ||
$result[$name] = $variation; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Qossmic\TwigDocBundle\Component\Data; | ||
|
||
use Symfony\Component\PropertyInfo\Type; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
readonly class FixtureData | ||
{ | ||
public function __construct( | ||
public string $className, | ||
/** @param array<string, Type> $properties */ | ||
public array $properties, | ||
public array $params = [] | ||
) { | ||
} | ||
} |
Oops, something went wrong.