1 | <?php |
||||||
2 | |||||||
3 | namespace Pyrowman\PheanstalkBundle\Command; |
||||||
4 | |||||||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||||||
6 | use Pheanstalk\Exception; |
||||||
7 | use Pheanstalk\Structure\Workflow; |
||||||
8 | use Symfony\Component\Console\Input\InputArgument; |
||||||
9 | use Symfony\Component\Console\Input\InputInterface; |
||||||
10 | use Symfony\Component\Console\Output\OutputInterface; |
||||||
11 | |||||||
12 | class DeleteWorkflowCommand extends AbstractPheanstalkCommand |
||||||
13 | { |
||||||
14 | /** |
||||||
15 | * @inheritdoc |
||||||
16 | */ |
||||||
17 | 4 | protected function configure() |
|||||
18 | { |
||||||
19 | $this |
||||||
20 | 4 | ->setName('pyrowman:pheanstalk:delete-workflow') |
|||||
21 | 4 | ->addArgument('name', InputArgument::REQUIRED, 'Workflow name to delete.') |
|||||
22 | 4 | ->addArgument('group', InputArgument::REQUIRED, 'Workflow group to delete.') |
|||||
23 | 4 | ->addArgument('pheanstalk', InputArgument::OPTIONAL, 'Pheanstalk name.') |
|||||
24 | 4 | ->setDescription('Delete the specified workflow if it exists.'); |
|||||
25 | } |
||||||
26 | |||||||
27 | /** |
||||||
28 | * @inheritdoc |
||||||
29 | */ |
||||||
30 | 4 | protected function execute(InputInterface $input, OutputInterface $output) |
|||||
31 | { |
||||||
32 | 4 | $workflowName = $input->getArgument('name'); |
|||||
33 | 4 | $workflowGroup = $input->getArgument('group'); |
|||||
34 | 4 | $name = $input->getArgument('pheanstalk'); |
|||||
35 | 4 | $pheanstalk = $this->getPheanstalk($name); |
|||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
36 | |||||||
37 | try { |
||||||
38 | 2 | $workflow = new Workflow($workflowName, $workflowGroup, new ArrayCollection([])); |
|||||
0 ignored issues
–
show
It seems like
$workflowName can also be of type null and string[] ; however, parameter $name of Pheanstalk\Structure\Workflow::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
$workflowGroup can also be of type null and string[] ; however, parameter $group of Pheanstalk\Structure\Workflow::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
39 | 2 | $pheanstalk->delete($workflow); |
|||||
40 | |||||||
41 | 1 | $output->writeln("Pheanstalk: <info>$name</info>"); |
|||||
42 | 1 | $output->writeln("Workflow <info>$workflowName</info> deleted."); |
|||||
43 | |||||||
44 | 1 | return 0; |
|||||
45 | 1 | } catch (Exception $e) { |
|||||
46 | 1 | $output->writeln("Pheanstalk: <info>$name</info>"); |
|||||
47 | 1 | $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); |
|||||
48 | |||||||
49 | 1 | return 1; |
|||||
50 | } |
||||||
51 | } |
||||||
52 | } |
||||||
53 |