Test Failed
Pull Request — master (#17)
by Evgeniy
08:59
created

MysqlMutexFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Mutex\Mysql;
6
7
use PDO;
8
use Yiisoft\Mutex\MutexFactory;
9
use Yiisoft\Mutex\MutexInterface;
10
11
/**
12
 * Allows creating {@see MysqlMutex} mutex objects.
13
 */
14
final class MysqlMutexFactory extends MutexFactory
15
{
16
    private PDO $connection;
17
18
    /**
19
     * @param PDO $connection PDO connection instance to use.
20
     */
21
    public function __construct(PDO $connection)
22
    {
23
        $this->connection = $connection;
24
    }
25
26
    public function create(string $name): MutexInterface
27
    {
28
        return new MysqlMutex($name, $this->connection);
29
    }
30
}
31