From 4b13802b5434a6f4cbfc002ad7cca5e21d6b824d Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Mon, 19 Aug 2024 09:36:26 +0300 Subject: [PATCH] chore: include notice about swagger, cleanup code --- gen/parser.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/gen/parser.php b/gen/parser.php index 88a1ad8..d8d3d1e 100644 --- a/gen/parser.php +++ b/gen/parser.php @@ -1,9 +1,20 @@ $vars) { // Get name of the class from filename and split CamelCase to words. @@ -84,7 +92,7 @@ foreach ($classes as $className => $vars) { $usesHeader = [ "", - "use Spatie\DataTransferObject\DataTransferObject;" + "use Spatie\DataTransferObject\DataTransferObject;", ]; $hasCasters = [ @@ -138,7 +146,6 @@ class $className extends DataTransferObject $file .= "\n" . implode("\n", $traits) . "\n"; } - foreach ($vars as $varKey => $varData) { if (in_array($varKey, $used, true)) { continue; @@ -158,6 +165,7 @@ class $className extends DataTransferObject } $default = $varData["default"] !== null ? " = " . $varData["default"] . ";" : ";"; + $file .= " /** * {$varData["docs"]}{$typeHelper} @@ -173,17 +181,9 @@ class $className extends DataTransferObject if (!empty($files)) { echo "Generating files:\n"; + $dtoDir = sprintf('%s%s%s%s%s', dirname(__FILE__, 2), DS, 'src', DS, 'Dto'); foreach ($files as $className => $file) { - $filePath = sprintf( - '%s%s%s%s%s%s%s.php', - dirname(__FILE__, 2), - DIRECTORY_SEPARATOR, - 'src', - DIRECTORY_SEPARATOR, - 'Dto', - DIRECTORY_SEPARATOR, - $className - ); + $filePath = sprintf('%s%s%s.php', $dtoDir, DS, $className); echo $filePath . "\n"; file_put_contents($filePath, $file); }