| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ray\AuraSqlModule; |
||
| 6 | |||
| 7 | use Aura\Sql\ExtendedPdo; |
||
| 8 | use Aura\Sql\ExtendedPdoInterface; |
||
| 9 | use Override; |
||
| 10 | use Ray\Di\AbstractModule; |
||
| 11 | use Ray\Di\Scope; |
||
| 12 | use SensitiveParameter; |
||
|
0 ignored issues
–
show
|
|||
| 13 | |||
| 14 | final class AuraSqlModule extends AbstractModule |
||
| 15 | { |
||
| 16 | public const PARSE_PDO_DSN_REGEX = '/(.*?):(?:(host|server)=.*?;)?(.*)/i'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param string $dsn Data Source Name (DSN) |
||
| 20 | * @param string $user User name for the DSN string |
||
| 21 | * @param string $password Password for the DSN string |
||
| 22 | * @param string $slave Comma separated slave host list |
||
| 23 | * @param array<string,mixed> $options A key=>value array of driver-specific connection options |
||
| 24 | * @param array<string> $queries |
||
| 25 | */ |
||
| 26 | public function __construct( |
||
| 27 | private readonly string $dsn, |
||
| 28 | private readonly string $user = '', |
||
| 29 | #[SensitiveParameter] |
||
| 30 | private readonly string $password = '', |
||
| 31 | private readonly string $slave = '', |
||
| 32 | /** @var array<string, mixed> */ |
||
| 33 | private readonly array $options = [], |
||
| 34 | /** @var array<string> */ |
||
| 35 | private readonly array $queries = [] |
||
| 36 | ) { |
||
| 37 | parent::__construct(); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritDoc} |
||
| 42 | */ |
||
| 43 | #[Override] |
||
| 44 | protected function configure(): void |
||
| 45 | { |
||
| 46 | $this->slave ? $this->configureMasterSlaveDsn() : $this->configureSingleDsn(); |
||
| 47 | $this->install(new AuraSqlBaseModule($this->dsn)); |
||
| 48 | } |
||
| 49 | |||
| 50 | private function configureSingleDsn(): void |
||
| 51 | { |
||
| 52 | $this->bind()->annotatedWith('pdo_dsn')->toInstance($this->dsn); |
||
| 53 | $this->bind()->annotatedWith('pdo_user')->toInstance($this->user); |
||
| 54 | $this->bind()->annotatedWith('pdo_pass')->toInstance($this->password); |
||
| 55 | $this->bind()->annotatedWith('pdo_slave')->toInstance($this->slave); |
||
| 56 | $this->bind()->annotatedWith('pdo_options')->toInstance($this->options); |
||
| 57 | $this->bind()->annotatedWith('pdo_queries')->toInstance($this->queries); |
||
| 58 | $this->bind(ExtendedPdoInterface::class)->toConstructor( |
||
| 59 | ExtendedPdo::class, |
||
| 60 | [ |
||
| 61 | 'dsn' => 'pdo_dsn', |
||
| 62 | 'username' => 'pdo_user', |
||
| 63 | 'password' => 'pdo_pass', |
||
| 64 | 'options' => 'pdo_options', |
||
| 65 | 'queries' => 'pdo_queries', |
||
| 66 | ], |
||
| 67 | )->in(Scope::SINGLETON); |
||
| 68 | } |
||
| 69 | |||
| 70 | private function configureMasterSlaveDsn(): void |
||
| 71 | { |
||
| 72 | $locator = ConnectionLocatorFactory::fromInstance( |
||
| 73 | $this->dsn, |
||
| 74 | $this->user, |
||
| 75 | $this->password, |
||
| 76 | $this->slave, |
||
| 77 | $this->options, |
||
| 78 | $this->queries, |
||
| 79 | ); |
||
| 80 | $this->install(new AuraSqlReplicationModule($locator)); |
||
| 81 | } |
||
| 82 | } |
||
| 83 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths