Skip to content

Commit 6c99753

Browse files
committed
:octocat: DatabaseOptions -> trait for ContainerInterface
1 parent 482fe1f commit 6c99753

File tree

2 files changed

+189
-174
lines changed

2 files changed

+189
-174
lines changed

src/DatabaseOptions.php

Lines changed: 1 addition & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
* @property int $mysqli_timeout
3434
* @property string $mysql_charset
3535
* @property string $pgsql_charset
36-
* @property string $sqlite_flags
37-
* @property string $sqlite_encryption_key
3836
* @property string $odbc_driver
3937
* @property string $convert_encoding_src
4038
* @property string $convert_encoding_dest
@@ -46,176 +44,5 @@
4644
* @property string $storage_path
4745
*/
4846
class DatabaseOptions implements ContainerInterface{
49-
use Container;
50-
51-
/**
52-
* The database driver to use (FQCN)
53-
*
54-
* @var string
55-
*/
56-
protected $driver;
57-
58-
/**
59-
* The host to connect to
60-
*
61-
* @var string
62-
*/
63-
protected $host = 'localhost';
64-
65-
/**
66-
* The port number
67-
*
68-
* @var int
69-
*/
70-
protected $port;
71-
72-
/**
73-
* A socket
74-
*
75-
* @var string
76-
*/
77-
protected $socket;
78-
79-
/**
80-
* The database name
81-
*
82-
* @var string
83-
*/
84-
protected $database;
85-
86-
/**
87-
* The username
88-
*
89-
* @var string
90-
*/
91-
protected $username;
92-
93-
/**
94-
* The password
95-
*
96-
* @var string
97-
*/
98-
protected $password;
99-
100-
/**
101-
* Indicates whether the connection should use SSL or not
102-
*
103-
* @var bool
104-
*/
105-
protected $use_ssl = false;
106-
107-
/**
108-
* The SSL key
109-
*
110-
* @var string
111-
*/
112-
protected $ssl_key;
113-
114-
/**
115-
* The SSL certificate
116-
*
117-
* @var string
118-
*/
119-
protected $ssl_cert;
120-
121-
/**
122-
* The path to a SSL certificate authority file
123-
*
124-
* @var string
125-
*/
126-
protected $ssl_ca;
127-
128-
/**
129-
* The directory containing SSL certificate authority files
130-
*
131-
* @var string
132-
*/
133-
protected $ssl_capath;
134-
135-
/**
136-
* The SSL cipher
137-
*
138-
* @var string
139-
*/
140-
protected $ssl_cipher;
141-
142-
/**
143-
* MySQLi connection timeout
144-
*
145-
* @var int
146-
*/
147-
protected $mysqli_timeout = 3;
148-
149-
/**
150-
* MySQL connection character set
151-
*
152-
* @link https://mathiasbynens.be/notes/mysql-utf8mb4 How to support full Unicode in MySQL
153-
*
154-
* @var string
155-
*/
156-
protected $mysql_charset = 'utf8mb4';
157-
158-
/**
159-
* PostgreSQL connection character set
160-
*
161-
* @var string
162-
*/
163-
protected $pgsql_charset = 'UTF8';
164-
165-
/**
166-
* The driver name to use for an ODBC connection
167-
*
168-
* @var string
169-
*/
170-
protected $odbc_driver;
171-
172-
/**
173-
* @var string database result encoding (mb_convert_encoding)
174-
*/
175-
protected $convert_encoding_src;
176-
177-
/**
178-
* @var string target encoding
179-
*/
180-
protected $convert_encoding_dest = 'UTF-8';
181-
182-
/**
183-
* MS SQL Server connection timeout
184-
*
185-
* @link https://docs.microsoft.com/en-us/sql/connect/php/connection-options
186-
*
187-
* @var int
188-
*/
189-
protected $mssql_timeout = 3;
190-
191-
/**
192-
* MS SQL Server connection character set
193-
*
194-
* @var string
195-
*/
196-
protected $mssql_charset = 'UTF-8';
197-
198-
/**
199-
* Specifies whether the communication with MS SQL Server is encrypted or unencrypted.
200-
*
201-
* @var bool
202-
*/
203-
protected $mssql_encrypt = false; // how???
204-
205-
/**
206-
* Firebird connection encoding
207-
*
208-
* @var string
209-
*/
210-
protected $firebird_encoding = 'UTF8';
211-
212-
/**
213-
* @var string
214-
*/
215-
protected $cachekey_hash_algo = 'sha256';
216-
217-
/**
218-
* @var
219-
*/
220-
protected $storage_path;
47+
use Container, DatabaseOptionsTrait;
22148
}

src/DatabaseOptionsTrait.php

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<?php
2+
/**
3+
* Trait DatabaseOptionsTrait
4+
*
5+
* @filesource DatabaseOptionsTrait.php
6+
* @created 24.01.2018
7+
* @package chillerlan\Database
8+
* @author Smiley <[email protected]>
9+
* @copyright 2018 Smiley
10+
* @license MIT
11+
*/
12+
13+
namespace chillerlan\Database;
14+
15+
trait DatabaseOptionsTrait{
16+
17+
/**
18+
* The database driver to use (FQCN)
19+
*
20+
* @var string
21+
*/
22+
protected $driver;
23+
24+
/**
25+
* The host to connect to
26+
*
27+
* @var string
28+
*/
29+
protected $host = 'localhost';
30+
31+
/**
32+
* The port number
33+
*
34+
* @var int
35+
*/
36+
protected $port;
37+
38+
/**
39+
* A socket
40+
*
41+
* @var string
42+
*/
43+
protected $socket;
44+
45+
/**
46+
* The database name
47+
*
48+
* @var string
49+
*/
50+
protected $database;
51+
52+
/**
53+
* The username
54+
*
55+
* @var string
56+
*/
57+
protected $username;
58+
59+
/**
60+
* The password
61+
*
62+
* @var string
63+
*/
64+
protected $password;
65+
66+
/**
67+
* Indicates whether the connection should use SSL or not
68+
*
69+
* @var bool
70+
*/
71+
protected $use_ssl = false;
72+
73+
/**
74+
* The SSL key
75+
*
76+
* @var string
77+
*/
78+
protected $ssl_key;
79+
80+
/**
81+
* The SSL certificate
82+
*
83+
* @var string
84+
*/
85+
protected $ssl_cert;
86+
87+
/**
88+
* The path to a SSL certificate authority file
89+
*
90+
* @var string
91+
*/
92+
protected $ssl_ca;
93+
94+
/**
95+
* The directory containing SSL certificate authority files
96+
*
97+
* @var string
98+
*/
99+
protected $ssl_capath;
100+
101+
/**
102+
* The SSL cipher
103+
*
104+
* @var string
105+
*/
106+
protected $ssl_cipher;
107+
108+
/**
109+
* MySQLi connection timeout
110+
*
111+
* @var int
112+
*/
113+
protected $mysqli_timeout = 3;
114+
115+
/**
116+
* MySQL connection character set
117+
*
118+
* @link https://mathiasbynens.be/notes/mysql-utf8mb4 How to support full Unicode in MySQL
119+
*
120+
* @var string
121+
*/
122+
protected $mysql_charset = 'utf8mb4';
123+
124+
/**
125+
* PostgreSQL connection character set
126+
*
127+
* @var string
128+
*/
129+
protected $pgsql_charset = 'UTF8';
130+
131+
/**
132+
* The driver name to use for an ODBC connection
133+
*
134+
* @var string
135+
*/
136+
protected $odbc_driver;
137+
138+
/**
139+
* @var string database result encoding (mb_convert_encoding)
140+
*/
141+
protected $convert_encoding_src;
142+
143+
/**
144+
* @var string target encoding
145+
*/
146+
protected $convert_encoding_dest = 'UTF-8';
147+
148+
/**
149+
* MS SQL Server connection timeout
150+
*
151+
* @link https://docs.microsoft.com/en-us/sql/connect/php/connection-options
152+
*
153+
* @var int
154+
*/
155+
protected $mssql_timeout = 3;
156+
157+
/**
158+
* MS SQL Server connection character set
159+
*
160+
* @var string
161+
*/
162+
protected $mssql_charset = 'UTF-8';
163+
164+
/**
165+
* Specifies whether the communication with MS SQL Server is encrypted or unencrypted.
166+
*
167+
* @var bool
168+
*/
169+
protected $mssql_encrypt = false; // how???
170+
171+
/**
172+
* Firebird connection encoding
173+
*
174+
* @var string
175+
*/
176+
protected $firebird_encoding = 'UTF8';
177+
178+
/**
179+
* @var string
180+
*/
181+
protected $cachekey_hash_algo = 'sha256';
182+
183+
/**
184+
* @var
185+
*/
186+
protected $storage_path;
187+
188+
}

0 commit comments

Comments
 (0)