Passed
Push — master ( 04da79...785494 )
by Tomasz
01:35
created

UseCase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 9 2
1
<?php
2
/**
3
 *
4
 * This file is part of the Aggrego.
5
 * (c) Tomasz Kunicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
namespace Aggrego\Neo4jIntegration\Api\Command\RunCommand;
13
14
use GraphAware\Neo4j\Client\Client;
15
use GraphAware\Neo4j\Client\Exception\Neo4jExceptionInterface;
16
17
class UseCase
18
{
19
    /** @var Client */
20
    private $client;
21
22
    public function __construct(Client $client)
23
    {
24
        $this->client = $client;
25
    }
26
27
    public function handle(Command $command): Response
28
    {
29
        try {
30
            $this->client->run($command->getCypherQuery());
31
        } catch (Neo4jExceptionInterface $e) {
32
            return Response::fail($e->getMessage());
33
        }
34
35
        return Response::ok();
36
    }
37
}
38