Created
April 10, 2018 18:18
-
-
Save viirre/60eacdf7e9179cb1a687bea217d77d6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DoesAwesomeStuff { | |
protected $meta = []; | |
protected $metaExtractor; | |
public function __construct($metaExtractor) | |
{ | |
$this->metaExtractor = $metaExtractor; | |
} | |
public function doesAwesomeness() | |
{ | |
// does awesome stuff | |
} | |
public function getMeta($key) | |
{ | |
return $this->metaExtractor->fetch($this->meta, $key); | |
} | |
public function setMeta($meta) | |
{ | |
if (! isset($meta['key'], $meta['value'])) { | |
throw new Exception('Bad meta data'); | |
} | |
$meta['created_by'] = auth()->id(); | |
$this->meta = $meta; | |
} | |
} | |
class DoesCoolStuff { | |
protected $meta = []; | |
protected $metaExtractor; | |
public function __construct($metaExtractor) | |
{ | |
$this->metaExtractor = $metaExtractor; | |
} | |
public function doesCoolStuff() | |
{ | |
// does cool stuff | |
} | |
public function getMeta($key) | |
{ | |
return $this->metaExtractor->fetch($this->meta, $key); | |
} | |
public function setMeta($meta) | |
{ | |
if (! isset($meta['key'], $meta['value'])) { | |
throw new Exception('Bad meta data'); | |
} | |
$this->meta = $meta; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment