-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate-classes.php
32 lines (23 loc) · 1.06 KB
/
generate-classes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
use BladeComponents\Undraw\Api\Illustration;
use BladeComponents\Undraw\Api\IllustrationsRequest;
use BladeComponents\Undraw\Api\IllustrationsResponse;
use BladeComponents\Undraw\Api\UndrawClient;
require 'vendor/autoload.php';
$undrawClient = new UndrawClient();
$illustrationsRequest = new IllustrationsRequest($undrawClient);
$hasMore = true;
$page = 0;
while ($hasMore) {
$illustrationsResponse = new IllustrationsResponse($illustrationsRequest->page($page));
$hasMore = $illustrationsResponse->hasMore();
$page = $illustrationsResponse->nextPage();
/** @var Illustration $illustration */
foreach ($illustrationsResponse->illustrations() as $illustration) {
$className = sprintf('Undraw%sComponent', $illustration->studly());
$fileName = sprintf('src/Components/Illustrations/%s.php', $className);
$dummyComponent = file_get_contents('stubs/DummyIllustrationComponent.stub');
$content = str_replace('DummyIllustrationComponent', $className, $dummyComponent);
file_put_contents($fileName, $content);
}
}