DeleteCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseResponse() 0 11 2
A getCommandLine() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheanstalk\Command;
6
7
use Pheanstalk\Contract\ResponseInterface;
8
use Pheanstalk\Contract\ResponseParserInterface;
9
use Pheanstalk\Exception;
10
use Pheanstalk\Response\ArrayResponse;
11
12
/**
13
 * The 'delete' command.
14
 * Permanently deletes an already-reserved job.
15
 */
16
class DeleteCommand extends JobCommand implements ResponseParserInterface
17
{
18 14
    public function getCommandLine(): string
19
    {
20 14
        return 'delete ' . $this->jobId;
21
    }
22
23 15
    public function parseResponse(string $responseLine, ?string $responseData): ArrayResponse
24
    {
25 15
        if ($responseLine == ResponseInterface::RESPONSE_NOT_FOUND) {
26 1
            throw new Exception\JobNotFoundException(sprintf(
27 1
                'Cannot delete job %u: %s',
28 1
                $this->jobId,
29
                $responseLine
30
            ));
31
        }
32
33 14
        return $this->createResponse($responseLine);
34
    }
35
}
36