Passed
Push — 6.0 ( ee4eb8...e26713 )
by Olivier
01:40
created

DefinedConnection::connect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ICanBoogie\ActiveRecord;
4
5
use ICanBoogie\ActiveRecord\Config\ConnectionDefinition;
6
7
/**
8
 * Iterables over defined connections.
9
 */
10
interface ConnectionIterator
11
{
12
    /**
13
     * Returns an iterator of defined connections.
14
     *
15
     * @return iterable<non-empty-string, DefinedConnection>
16
     *     Where _key_ is a connection identifier.
17
     */
18
    public function connection_iterator(): iterable;
19
}
20
21
/**
22
 * @internal
23
 */
24
final class DefinedConnection {
25
    public function __construct(
26
        public readonly ConnectionDefinition $definition,
27
        public readonly bool $established,
28
        private readonly ConnectionProvider $provider,
29
    ) {
30
    }
31
32
    public function connect(): Connection
33
    {
34
        return $this->provider->connection_for_id($this->definition->id);
35
    }
36
}
37