Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DdbbFactory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 for
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace UppServices;
6
7/**
8 * Builds a DdbbService instance bound to a given source (e.g. __FILE__).
9 * Use for(__FILE__) in your class so the client identifier is linked to the file
10 * that obtains the connection (for logging and tracing).
11 *
12 * Example:
13 *   $ddbb = $ddbbFactory->for(__FILE__);
14 *   $conx = $ddbb->connect(\AppConstants::ddbbSchema());
15 */
16class DdbbFactory
17{
18    /**
19     * Returns a DdbbService bound to $client. Call connect($database) on it.
20     *
21     * @param string $client Client identifier for traces (e.g. __FILE__ or a logical name).
22     * @return DdbbService Instance with that client; connect(?string $database = null) only.
23     */
24    public function for(string $client): DdbbService
25    {
26        return new DdbbService($client);
27    }
28}