mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-30 12:07:32 +00:00
:octocat: added container trait
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Trait Container
|
||||
*
|
||||
* @filesource Container.php
|
||||
* @created 09.07.2017
|
||||
* @package chillerlan\QRCode
|
||||
* @author Smiley <smiley@chillerlan.net>
|
||||
* @copyright 2017 Smiley
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCode;
|
||||
|
||||
/**
|
||||
* a generic container with getter and setter
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
trait Container{
|
||||
|
||||
/**
|
||||
* Boa constructor.
|
||||
*
|
||||
* @param array $properties
|
||||
*/
|
||||
public function __construct(array $properties = []){
|
||||
|
||||
foreach($properties as $key => $value){
|
||||
$this->__set($key, $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* David Getter
|
||||
*
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $property){
|
||||
|
||||
if(property_exists($this, $property)){
|
||||
return $this->{$property};
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jet-setter
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $property, $value){
|
||||
|
||||
if(property_exists($this, $property)){
|
||||
$this->{$property} = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,10 +12,13 @@
|
||||
|
||||
namespace chillerlan\QRCode\Output;
|
||||
|
||||
use chillerlan\QRCode\Container;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class QROutputOptionsAbstract{
|
||||
use Container;
|
||||
|
||||
public $type;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace chillerlan\QRCode;
|
||||
*
|
||||
*/
|
||||
class QROptions{
|
||||
use Container;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
||||
Reference in New Issue
Block a user