Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3769357
D593.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D593.diff
View Options
diff --git a/src/DockerHubImage.php b/src/DockerHubImage.php
new file mode 100644
--- /dev/null
+++ b/src/DockerHubImage.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Keruald\DockerHub;
+
+/**
+ * Represents a DockerHub image.
+ */
+class DockerHubImage extends DockerImage {
+
+ public function getRegistryUrl () {
+ return "https://registry.hub.docker.com/u/$this->user/$this->image";
+ }
+
+}
diff --git a/src/DockerImage.php b/src/DockerImage.php
new file mode 100644
--- /dev/null
+++ b/src/DockerImage.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Keruald\DockerHub;
+
+abstract class DockerImage {
+
+ ///
+ /// Public properties
+ ///
+
+ /**
+ * @var string
+ */
+ public $registry;
+
+ /**
+ * @var string
+ */
+ public $user;
+
+ /**
+ * @var string
+ */
+ public $image;
+
+ ///
+ /// Constructor
+ ///
+
+ /**
+ * Initializes a new instance of a DockerImage object.
+ *
+ * @param string $user
+ * @param string $image
+ */
+ public function __construct ($user, $image) {
+ $this->user = $user;
+ $this->image = $image;
+ }
+
+ ///
+ /// Helper methods
+ ///
+
+ /**
+ * Gets the URL to the image on the registry.
+ *
+ * @return string
+ */
+ public abstract function getRegistryUrl();
+
+}
diff --git a/tests/DockerHubImageTest.php b/tests/DockerHubImageTest.php
new file mode 100644
--- /dev/null
+++ b/tests/DockerHubImageTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Keruald\DockerHub\Tests;
+
+use Keruald\DockerHub\DockerHubImage;
+
+class DockerHubImageTest extends \PHPUnit_Framework_TestCase {
+
+ public function testGetRegistryUrl () {
+ $image = new DockerHubImage("acme", "foo");
+ $this->assertSame(
+ "https://registry.hub.docker.com/u/acme/foo",
+ $image->getRegistryUrl()
+ );
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 14:18 (7 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260345
Default Alt Text
D593.diff (1 KB)
Attached To
Mode
D593: DockerHubImage class
Attached
Detach File
Event Timeline
Log In to Comment