Completed
Push — master ( 21b220...14b13a )
by Martin
03:51
created

MySqlDsn::toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the Yep package.
4
 * Copyright (c) 2016 Martin Zeman (Zemistr) (http://www.zemistr.eu)
5
 */
6
7
namespace Yep\Dsn;
8
9
/**
10
 * Class MySQLDsn
11
 *
12
 * @package Yep\Dsn
13
 * @author  Martin Zeman (Zemistr) <[email protected]>
14
 *
15
 * PDO_MYSQL
16
 * mysql:host=localhost;dbname=testdb
17
 * mysql:host=localhost;port=3307;dbname=testdb
18
 */
19
class MySqlDsn extends BaseDns {
20
  public function __construct(string $dbName, string $host = 'localhost', int $port = 3306) {
21
    $this->setDbName($dbName);
22
    $this->setHost($host);
23
    $this->setPort($port);
24
  }
25
26
  /**
27
   * @return string
28
   */
29
  public function toString() : string {
30
    return 'mysql:host=' . $this->getHost() . ';dbname=' . $this->getDbName() . ';port=' . $this->getPort();
31
  }
32
}
33