Issues (22)

ConnectionFactory/PrimeConnectionFactory.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Bdf\QueueBundle\ConnectionFactory;
4
5
use Bdf\Queue\Connection\ConnectionDriverInterface;
6
use Bdf\Queue\Connection\Prime\PrimeConnection;
0 ignored issues
show
The type Bdf\Queue\Connection\Prime\PrimeConnection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Bdf\Queue\Serializer\SerializerInterface;
8
use Psr\Container\ContainerInterface;
9
10
/**
11
 * Create a prime connection from "b2pweb/bdf-queue-prime-adapter".
12
 *
13
 * Use "prime" key as driver to create a prime connection.
14
 * ex:
15
 *  `prime://{prime_connection_name}?table={db_table}`
16
 */
17
class PrimeConnectionFactory implements ConnectionDriverConfiguratorInterface
18
{
19
    /**
20
     * @var ContainerInterface
21
     */
22
    private $container;
23
24 6
    public function __construct(ContainerInterface $container)
25
    {
26 6
        $this->container = $container;
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32 6
    public function getSupportedDrivers(): array
33
    {
34 6
        return ['prime'];
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 1
    public function configure(Configuration $config, SerializerInterface $serializer): ConnectionDriverInterface
41
    {
42 1
        if (!class_exists(PrimeConnection::class)) {
43
            throw new \LogicException('Could not create the prime connection bdf-queue. Try to composer require "b2pweb/bdf-queue-prime-adapter" to add this class.');
44
        }
45
46 1
        $connection = new PrimeConnection($config->getConnection(), $serializer, $this->container->get('prime')->connections());
47 1
        $connection->setConfig($config->toArray());
48
49 1
        return $connection;
50
    }
51
}
52