Skip to content

Commit 941674f

Browse files
committed
feat: use getters and setters to get/set on the Doctum class
1 parent e9fcc7e commit 941674f

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

src/Console/Command/Command.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,16 @@ protected function initialize(InputInterface $input, OutputInterface $output)
111111

112112
$this->doctum = $this->loadDoctum($config);
113113

114-
if ($input->getOption('only-version')) {
115-
$this->doctum['versions'] = $input->getOption('only-version');
116-
}
117-
118114
if (!$this->doctum instanceof Doctum) {
119115
throw new \RuntimeException(sprintf('Configuration file "%s" must return a Doctum instance.', $config));
120116
}
117+
118+
if ($input->getOption('only-version')) {
119+
/** @var string $onlyVersionOption */
120+
$onlyVersionOption = $input->getOption('only-version');
121+
$this->doctum->setVersion((string) $onlyVersionOption);
122+
}
123+
121124
}
122125

123126
public function update(Project $project): int

src/Console/Command/ParseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
6161
{
6262
$output->writeln('<bg=cyan;fg=white> Parsing project </>');
6363

64-
return $this->parse($this->doctum['project']);
64+
return $this->parse($this->doctum->getProject());
6565
}
6666
}

src/Console/Command/RenderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
6060
{
6161
$output->writeln('<bg=cyan;fg=white> Rendering project </>');
6262

63-
return $this->render($this->doctum['project']);
63+
return $this->render($this->doctum->getProject());
6464
}
6565
}

src/Console/Command/UpdateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
5151
{
5252
$output->writeln('<bg=cyan;fg=white> Updating project </>');
5353

54-
return $this->update($this->doctum['project']);
54+
return $this->update($this->doctum->getProject());
5555
}
5656
}

src/Doctum.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,14 @@ public function __construct($iterator = null, array $config = [])
210210
$this[$key] = $value;
211211
}
212212
}
213+
214+
public function setVersion(string $version): void
215+
{
216+
$this['versions'] = $version;
217+
}
218+
219+
public function getProject(): Project
220+
{
221+
return $this['project'];
222+
}
213223
}

0 commit comments

Comments
 (0)