Skip to content

Commit

Permalink
Clarify Activity type
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 18, 2024
1 parent f8e15d8 commit 75c2483
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Command/Activity/ActivityGetCommand.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace Platformsh\Cli\Command\Activity;

use Platformsh\Cli\Model\Activity;
use Platformsh\Cli\Selector\SelectorConfig;
use Platformsh\Cli\Selector\Selector;
use Platformsh\Cli\Service\Api;
Expand All @@ -11,6 +10,7 @@
use Platformsh\Cli\Service\ActivityMonitor;
use Platformsh\Cli\Service\PropertyFormatter;
use Platformsh\Cli\Service\Table;
use Platformsh\Client\Model\Activity;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -74,12 +74,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$activity = $selection->getProject()
->getActivity($id);
if (!$activity) {
/** @var Activity $activity */
$activity = $this->api->matchPartialId($id, $this->activityLoader->loadFromInput($apiResource, $input, 10) ?: [], 'Activity');
}
} else {
$activities = $this->activityLoader->loadFromInput($apiResource, $input, 1);
/** @var Activity|false $activity */
$activity = reset($activities);
if (!$activity) {
$this->stdErr->writeln('No activities found');
Expand All @@ -88,6 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

/** @var Activity $activity */
$properties = $activity->getProperties();

if (!$input->getOption('property') && !$this->table->formatIsMachineReadable()) {
Expand All @@ -98,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// Add the fake "duration" property.
if (!isset($properties['duration'])) {
$properties['duration'] = (new Activity())->getDuration($activity);
$properties['duration'] = (new \Platformsh\Cli\Model\Activity())->getDuration($activity);
}

if ($property = $input->getOption('property')) {
Expand Down

0 comments on commit 75c2483

Please sign in to comment.