mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-10 16:04:57 +02:00
51 lines
829 B
PHP
51 lines
829 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\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;
|
|
}
|
|
}
|