From a4897792238b47a538871f0c3af562bee9d1a472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Helland?= Date: Tue, 8 Sep 2015 15:04:24 +0200 Subject: [PATCH] Public methods for getting host and extension on media --- src/Keyteq/Keymedia/Model/Media.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Keyteq/Keymedia/Model/Media.php b/src/Keyteq/Keymedia/Model/Media.php index c23958d..fb38e90 100644 --- a/src/Keyteq/Keymedia/Model/Media.php +++ b/src/Keyteq/Keymedia/Model/Media.php @@ -40,9 +40,13 @@ public function getUrl() return $this->file['url']; } - protected function getHost($protocol = 'http') + /** + * @param string/false $protocol false to get host without protocol + * @return string + */ + public function getHost($protocol = 'http') { - return "{$protocol}://{$this->host}"; + return $protocol === false ? $this->host : "{$protocol}://{$this->host}"; } public function getShareUrl() @@ -89,7 +93,7 @@ protected function getImageThumbnailUrl($width, $height) return $this->buildUrl("{$width}x{$height}/{$this->_id}.{$ending}"); } - protected function getExtension() + public function getExtension() { if ($this->file && isset($this->file['ending'])) { $ending = $this->file['ending'];