We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement CreateNewFileForRoadyProjectAction for Rig v2.0.0
class CreateNewFileForRoadyProjectAction extends Action { public function __construct( private Arguments $arguments, private MessageLog $messageLog, private RoadyProjectPathInfo $roadyProjectPathInfo, private string $relativePathToNewFile, private Name $fileName, private string $content, ) { parent::__construct($this->arguments, $this->messageLog); } public function do(): CreateNewFileForRoadyProjectAction { $this->attemptToCreateNewFile(); $this->messageLog()->addMessage( match($this->actionStatus()) { ActionStatus::FAILED => CLIColorizer::applyFAILEDColor( 'Failed to create new file ' . $this->pathToNewFile() ), ActionStatus::SUCCEEDED => CLIColorizer::applySUCCEEDEDColor( 'Created new file ' . $this->pathToNewFile() ), ActionStatus::NOT_PROCESSED => CLIColorizer::applyNOT_PROCESSEDColor( 'Creation of new file '. $this->pathToNewFile() . 'was not processed.' ), } ); return $this; } private function content(): string { return trim($this->content); } private function roadyProjectPathInfo(): RoadyProjectPathInfo { return $this->roadyProjectPathInfo; } private function attemptToCreateNewFile(): void { $this->actionStatus = match( !file_exists($this->pathToNewFile()) && (file_put_contents($this->pathToNewFile(), $this->content()) > 0) ) { true => ActionStatus::SUCCEEDED, false => ActionStatus::FAILED, }; } private function fileName(): Name { return $this->fileName; } private function pathToNewFile(): string { $safePathParts = $this->roadyProjectPathInfo() ->pathToSafeTextCollection( $this->relativePathToNewFile ); $safePath = DIRECTORY_SEPARATOR; foreach($safePathParts->collection() as $safePathPart) { $safePath .= $safePathPart->__toString() . DIRECTORY_SEPARATOR; } $safePath .= $this->fileName(); return $this->roadyProjectPathInfo() ->expectedPathToRoadyProjectsRootDirectory() ->__toString() . $safePath; } }
The text was updated successfully, but these errors were encountered:
sevidmusic
No branches or pull requests
Implement CreateNewFileForRoadyProjectAction for Rig v2.0.0
The text was updated successfully, but these errors were encountered: