bradyvercher / gistpress

WordPress plugin to add Gist oEmbed and shortcode support with caching.
GNU General Public License v2.0
143 stars 28 forks source link

Refactor transient key #5

Closed GaryJones closed 11 years ago

GaryJones commented 11 years ago

Strings like the transient key, {{unknown}} and other strings used across multiple methods should be refactored into protected functions e.g.

protected function transient_key( $hash ) {
    return 'gist_html_' . $hash;
}

This ensures consistency, easy unit testability, and a single place to make changes if needed in the future.

bradyvercher commented 11 years ago

For strings like {{unknown}}, should those still go in a method, or is a property fine?

GaryJones commented 11 years ago

Methods are testable, and they also allow the use of other functions or methods to help set a value, which properties do not, so methods are preferred over properties.