Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3766713
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/Build/TriggerBuildFactory.php b/src/Build/TriggerBuildFactory.php
index d04614f..f791e67 100644
--- a/src/Build/TriggerBuildFactory.php
+++ b/src/Build/TriggerBuildFactory.php
@@ -1,92 +1,99 @@
<?php
namespace Keruald\DockerHub\Build;
use Keruald\DockerHub\DockerHubImage;
use GuzzleHttp\ClientInterface;
use InvalidArgumentException;
/**
* Allows to build several TriggerBuild instances
* with the same HTTP client and a collection of tokens.
*/
class TriggerBuildFactory {
///
/// Private members, to pass to instances
///
/**
* @var $array
*/
private $tokens;
/**
* @var \GuzzleHttp\ClientInterface
*/
private $client;
///
/// Constructor
///
/**
* Initializes a new instance of the TriggerBuildFactory object.
*
* @param \GuzzleHttp\ClientInterface $client HTTP client
* @param array $tokens The tokens for the image
*/
public function __construct (ClientInterface $client, array $tokens) {
$this->client = $client;
$this->tokens = $tokens;
}
///
/// Builder
///
/**
* Builds a new TriggerBuild instance for the specified image.
*
* @param string $image The image name
* @return TriggerBuild
*/
public function getForImage ($image) {
return new TriggerBuild(
DockerHubImage::loadFromSlashNotation($image),
$this->getToken($image),
$this->client
);
}
/**
* Sends to registry a payload to trigger a build for the specified image.
*
* @param string $image The image name
*/
public function build ($image) {
$this->getForImage($image)->sendPayloadForAll();
}
/**
- * @return bool
+ * Determines if we've a token for the specified image.
+ *
+ * @return bool true if we've a token for this image; otherwise, false.
*/
public function hasToken ($image) {
return array_key_exists($image, $this->tokens);
}
///
/// Helper methods
///
+ /**
+ * Gets the token associated to an image.
+ *
+ * @return string
+ */
protected function getToken ($image) {
if ($this->hasToken($image)) {
return $this->tokens[$image];
}
throw new InvalidArgumentException("No token found for image $image.");
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Nov 24, 19:41 (5 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2258799
Default Alt Text
(2 KB)
Attached To
Mode
rKDOCKERHUB Keruald Docker Hub
Attached
Detach File
Event Timeline
Log In to Comment