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

UseCase::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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