Last active
May 30, 2018 08:42
-
-
Save coenjacobs/274095c1bc6a88b94e94952f68c5722f 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 MetaChecker { | |
public function checkMeta( WP_Post $post ) { | |
$value = get_post_meta($post->ID, 'key_of_value_store', true); | |
// @TODO: Do magic with $value | |
} | |
} |
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 MetaChecker { | |
/** @var MetaRepository */ | |
public $metaRepository; | |
public function __construct( MetaRepository $metaRepository ) { | |
$this->metaRepository = $metaRepository; | |
} | |
public function checkMeta( WP_Post $post ) { | |
$value = $this->metaRepository->getMeta($post, 'key_of_value_store', true); | |
// @TODO: Do magic with $value | |
} | |
} |
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 | |
interface MetaRepository { | |
public function getMeta( WP_Post $post, $key, $single ); | |
} | |
class WordPressMetaRepository implements MetaRepository { | |
public function getMeta( WP_Post $post, $key, $single ) { | |
return get_post_meta($post->ID, $key, $single); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment