Skip to content

Instantly share code, notes, and snippets.

@viirre
Created April 10, 2018 18:18
Show Gist options
  • Save viirre/60eacdf7e9179cb1a687bea217d77d6d to your computer and use it in GitHub Desktop.
Save viirre/60eacdf7e9179cb1a687bea217d77d6d to your computer and use it in GitHub Desktop.
<?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