Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| PdoBuilder | |
0.00% |
0 / 9 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
| dsn | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| username | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| password | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| options | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| build | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Dynart\Micro\Entities; |
| 4 | |
| 5 | use PDO; |
| 6 | |
| 7 | class PdoBuilder { |
| 8 | |
| 9 | protected string $dsn = ''; |
| 10 | protected string $username = ''; |
| 11 | protected string $password = ''; |
| 12 | protected array $options = []; |
| 13 | |
| 14 | public function dsn(string $value): static { |
| 15 | $this->dsn = $value; |
| 16 | return $this; |
| 17 | } |
| 18 | |
| 19 | public function username(string $value): static { |
| 20 | $this->username = $value; |
| 21 | return $this; |
| 22 | } |
| 23 | |
| 24 | public function password(string $value): static { |
| 25 | $this->password = $value; |
| 26 | return $this; |
| 27 | } |
| 28 | |
| 29 | public function options(array $value): static { |
| 30 | $this->options = $value; |
| 31 | return $this; |
| 32 | } |
| 33 | |
| 34 | public function build(): PDO { |
| 35 | return new PDO($this->dsn, $this->username, $this->password, $this->options); |
| 36 | } |
| 37 | } |