mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-08 16:06:31 +02:00
start a restructure
This commit is contained in:
49
Structural/DependencyInjection/Connection.php
Normal file
49
Structural/DependencyInjection/Connection.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\DependencyInjection;
|
||||
|
||||
/**
|
||||
* Class Connection
|
||||
*/
|
||||
class Connection
|
||||
{
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
protected $configuration;
|
||||
|
||||
/**
|
||||
* @var Currently connected host
|
||||
*/
|
||||
protected $host;
|
||||
|
||||
/**
|
||||
* @param Parameters $config
|
||||
*/
|
||||
public function __construct(Parameters $config)
|
||||
{
|
||||
$this->configuration = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* connection using the injected config
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
$host = $this->configuration->get('host');
|
||||
// connection to host, authentication etc...
|
||||
|
||||
//if connected
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get currently connected host
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user