repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mpyw/co | src/Co.php | Co.processGeneratorContainerDone | private function processGeneratorContainerDone(GeneratorContainer $gc)
{
// If exception has been thrown in generator, we have to propagate it as rejected value
if ($gc->thrown()) {
return new RejectedPromise($gc->getReturnOrThrown());
}
// Now we normalize returned value
$returned = YieldableUtils::normalize($gc->getReturnOrThrown(), $gc->getYieldKey());
$yieldables = YieldableUtils::getYieldables($returned, [], $this->runners);
// If normalized value contains yieldables, we have to chain resolver
if ($yieldables) {
$deferred = new Deferred;
return $this->promiseAll($yieldables, true)
->then(
YieldableUtils::getApplier($returned, $yieldables, [$deferred, 'resolve']),
[$deferred, 'reject']
)
->then(function () use ($yieldables, $deferred) {
$this->runners = array_diff_key($this->runners, $yieldables);
return $deferred->promise();
});
}
// Propagate normalized returned value
return new FulfilledPromise($returned);
} | php | private function processGeneratorContainerDone(GeneratorContainer $gc)
{
// If exception has been thrown in generator, we have to propagate it as rejected value
if ($gc->thrown()) {
return new RejectedPromise($gc->getReturnOrThrown());
}
// Now we normalize returned value
$returned = YieldableUtils::normalize($gc->getReturnOrThrown(), $gc->getYieldKey());
$yieldables = YieldableUtils::getYieldables($returned, [], $this->runners);
// If normalized value contains yieldables, we have to chain resolver
if ($yieldables) {
$deferred = new Deferred;
return $this->promiseAll($yieldables, true)
->then(
YieldableUtils::getApplier($returned, $yieldables, [$deferred, 'resolve']),
[$deferred, 'reject']
)
->then(function () use ($yieldables, $deferred) {
$this->runners = array_diff_key($this->runners, $yieldables);
return $deferred->promise();
});
}
// Propagate normalized returned value
return new FulfilledPromise($returned);
} | [
"private",
"function",
"processGeneratorContainerDone",
"(",
"GeneratorContainer",
"$",
"gc",
")",
"{",
"// If exception has been thrown in generator, we have to propagate it as rejected value",
"if",
"(",
"$",
"gc",
"->",
"thrown",
"(",
")",
")",
"{",
"return",
"new",
"R... | Handle resolving generators already done.
@param GeneratorContainer $gc
@return PromiseInterface | [
"Handle",
"resolving",
"generators",
"already",
"done",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Co.php#L161-L188 | train |
mpyw/co | src/Co.php | Co.processGeneratorContainerRunning | private function processGeneratorContainerRunning(GeneratorContainer $gc)
{
// Check delay request yields
if ($gc->key() === CoInterface::DELAY) {
return $this->pool->addDelay($gc->current())
->then(function () use ($gc) {
$gc->send(null);
return $this->processGeneratorContainer($gc);
});
}
// Now we normalize yielded value
$yielded = YieldableUtils::normalize($gc->current());
$yieldables = YieldableUtils::getYieldables($yielded, [], $this->runners);
if (!$yieldables) {
// If there are no yieldables, send yielded value back into generator
$gc->send($yielded);
// Continue
return $this->processGeneratorContainer($gc);
}
// Chain resolver
return $this->promiseAll($yieldables, $gc->key() !== CoInterface::SAFE)
->then(
YieldableUtils::getApplier($yielded, $yieldables, [$gc, 'send']),
[$gc, 'throw_']
)->then(function () use ($gc, $yieldables) {
// Continue
$this->runners = array_diff_key($this->runners, $yieldables);
return $this->processGeneratorContainer($gc);
});
} | php | private function processGeneratorContainerRunning(GeneratorContainer $gc)
{
// Check delay request yields
if ($gc->key() === CoInterface::DELAY) {
return $this->pool->addDelay($gc->current())
->then(function () use ($gc) {
$gc->send(null);
return $this->processGeneratorContainer($gc);
});
}
// Now we normalize yielded value
$yielded = YieldableUtils::normalize($gc->current());
$yieldables = YieldableUtils::getYieldables($yielded, [], $this->runners);
if (!$yieldables) {
// If there are no yieldables, send yielded value back into generator
$gc->send($yielded);
// Continue
return $this->processGeneratorContainer($gc);
}
// Chain resolver
return $this->promiseAll($yieldables, $gc->key() !== CoInterface::SAFE)
->then(
YieldableUtils::getApplier($yielded, $yieldables, [$gc, 'send']),
[$gc, 'throw_']
)->then(function () use ($gc, $yieldables) {
// Continue
$this->runners = array_diff_key($this->runners, $yieldables);
return $this->processGeneratorContainer($gc);
});
} | [
"private",
"function",
"processGeneratorContainerRunning",
"(",
"GeneratorContainer",
"$",
"gc",
")",
"{",
"// Check delay request yields",
"if",
"(",
"$",
"gc",
"->",
"key",
"(",
")",
"===",
"CoInterface",
"::",
"DELAY",
")",
"{",
"return",
"$",
"this",
"->",
... | Handle resolving generators still running.
@param GeneratorContainer $gc
@return PromiseInterface | [
"Handle",
"resolving",
"generators",
"still",
"running",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Co.php#L195-L226 | train |
mpyw/co | src/Co.php | Co.getRootGenerator | private function getRootGenerator($throw, $value, &$return)
{
try {
if ($throw !== null) {
$key = $throw ? null : CoInterface::SAFE;
} else {
$key = $this->options['throw'] ? null : CoInterface::SAFE;
}
$return = (yield $key => $value);
return;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->pool->reserveHaltException($e);
} | php | private function getRootGenerator($throw, $value, &$return)
{
try {
if ($throw !== null) {
$key = $throw ? null : CoInterface::SAFE;
} else {
$key = $this->options['throw'] ? null : CoInterface::SAFE;
}
$return = (yield $key => $value);
return;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->pool->reserveHaltException($e);
} | [
"private",
"function",
"getRootGenerator",
"(",
"$",
"throw",
",",
"$",
"value",
",",
"&",
"$",
"return",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"throw",
"!==",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"throw",
"?",
"null",
":",
"CoInterface",
"::",
... | Return root wrapper generator.
@param mixed $throw
@param mixed $value
@param mixed &$return | [
"Return",
"root",
"wrapper",
"generator",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Co.php#L234-L246 | train |
mpyw/co | src/Co.php | Co.promiseAll | private function promiseAll(array $yieldables, $throw_acceptable)
{
$promises = [];
foreach ($yieldables as $yieldable) {
// Add or enqueue cURL handles
if (TypeUtils::isCurl($yieldable['value'])) {
$promises[(string)$yieldable['value']] = $this->pool->addCurl($yieldable['value']);
continue;
}
// Process generators
if (TypeUtils::isGeneratorContainer($yieldable['value'])) {
$promises[(string)$yieldable['value']] = $this->processGeneratorContainer($yieldable['value']);
continue;
}
}
// If caller cannot accept exception,
// we handle rejected value as resolved.
if (!$throw_acceptable) {
$promises = array_map(
['\mpyw\Co\Internal\YieldableUtils', 'safePromise'],
$promises
);
}
return \React\Promise\all($promises);
} | php | private function promiseAll(array $yieldables, $throw_acceptable)
{
$promises = [];
foreach ($yieldables as $yieldable) {
// Add or enqueue cURL handles
if (TypeUtils::isCurl($yieldable['value'])) {
$promises[(string)$yieldable['value']] = $this->pool->addCurl($yieldable['value']);
continue;
}
// Process generators
if (TypeUtils::isGeneratorContainer($yieldable['value'])) {
$promises[(string)$yieldable['value']] = $this->processGeneratorContainer($yieldable['value']);
continue;
}
}
// If caller cannot accept exception,
// we handle rejected value as resolved.
if (!$throw_acceptable) {
$promises = array_map(
['\mpyw\Co\Internal\YieldableUtils', 'safePromise'],
$promises
);
}
return \React\Promise\all($promises);
} | [
"private",
"function",
"promiseAll",
"(",
"array",
"$",
"yieldables",
",",
"$",
"throw_acceptable",
")",
"{",
"$",
"promises",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"yieldables",
"as",
"$",
"yieldable",
")",
"{",
"// Add or enqueue cURL handles",
"if",
"(... | Promise all changes in yieldables are prepared.
@param array $yieldables
@param bool $throw_acceptable
@return PromiseInterface | [
"Promise",
"all",
"changes",
"in",
"yieldables",
"are",
"prepared",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Co.php#L254-L278 | train |
mpyw/co | src/Internal/Delayer.php | Delayer.add | public function add($time)
{
$deferred = new Deferred;
$time = filter_var($time, FILTER_VALIDATE_FLOAT);
if ($time === false) {
throw new \InvalidArgumentException('Delay must be number.');
}
if ($time < 0) {
throw new \DomainException('Delay must be positive.');
}
do {
$id = uniqid();
} while (isset($this->untils[$id]));
$this->untils[$id] = microtime(true) + $time;
$this->deferreds[$id] = $deferred;
return $deferred->promise();
} | php | public function add($time)
{
$deferred = new Deferred;
$time = filter_var($time, FILTER_VALIDATE_FLOAT);
if ($time === false) {
throw new \InvalidArgumentException('Delay must be number.');
}
if ($time < 0) {
throw new \DomainException('Delay must be positive.');
}
do {
$id = uniqid();
} while (isset($this->untils[$id]));
$this->untils[$id] = microtime(true) + $time;
$this->deferreds[$id] = $deferred;
return $deferred->promise();
} | [
"public",
"function",
"add",
"(",
"$",
"time",
")",
"{",
"$",
"deferred",
"=",
"new",
"Deferred",
";",
"$",
"time",
"=",
"filter_var",
"(",
"$",
"time",
",",
"FILTER_VALIDATE_FLOAT",
")",
";",
"if",
"(",
"$",
"time",
"===",
"false",
")",
"{",
"throw"... | Add delay.
@param int $time
@return PromiseInterface | [
"Add",
"delay",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/Delayer.php#L26-L42 | train |
mpyw/co | src/Internal/Delayer.php | Delayer.sleep | public function sleep()
{
$now = microtime(true);
$min = null;
foreach ($this->untils as $id => $until) {
$diff = $until - $now;
if ($diff < 0) {
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
}
if ($min !== null && $diff >= $min) {
continue;
}
$min = $diff;
}
$min && usleep($min * 1000000);
} | php | public function sleep()
{
$now = microtime(true);
$min = null;
foreach ($this->untils as $id => $until) {
$diff = $until - $now;
if ($diff < 0) {
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
}
if ($min !== null && $diff >= $min) {
continue;
}
$min = $diff;
}
$min && usleep($min * 1000000);
} | [
"public",
"function",
"sleep",
"(",
")",
"{",
"$",
"now",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"min",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"untils",
"as",
"$",
"id",
"=>",
"$",
"until",
")",
"{",
"$",
"diff",
"=",
"$",
... | Sleep at least required. | [
"Sleep",
"at",
"least",
"required",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/Delayer.php#L47-L64 | train |
mpyw/co | src/Internal/Delayer.php | Delayer.consume | public function consume()
{
foreach ($this->untils as $id => $until) {
$diff = $until - microtime(true);
if ($diff > 0.0 || !isset($this->deferreds[$id])) {
continue;
}
$deferred = $this->deferreds[$id];
unset($this->deferreds[$id], $this->untils[$id]);
$deferred->resolve(null);
}
} | php | public function consume()
{
foreach ($this->untils as $id => $until) {
$diff = $until - microtime(true);
if ($diff > 0.0 || !isset($this->deferreds[$id])) {
continue;
}
$deferred = $this->deferreds[$id];
unset($this->deferreds[$id], $this->untils[$id]);
$deferred->resolve(null);
}
} | [
"public",
"function",
"consume",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"untils",
"as",
"$",
"id",
"=>",
"$",
"until",
")",
"{",
"$",
"diff",
"=",
"$",
"until",
"-",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"$",
"diff",
">",
"0... | Consume delay queue. | [
"Consume",
"delay",
"queue",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/Delayer.php#L69-L80 | train |
mpyw/co | src/Internal/AbstractScheduler.php | AbstractScheduler.consume | public function consume()
{
$entries = $this->readCompletedEntries();
foreach ($entries as $entry) {
curl_multi_remove_handle($this->mh, $entry['handle']);
unset($this->added[(string)$entry['handle']]);
$this->interruptConsume();
}
$this->resolveEntries($entries);
} | php | public function consume()
{
$entries = $this->readCompletedEntries();
foreach ($entries as $entry) {
curl_multi_remove_handle($this->mh, $entry['handle']);
unset($this->added[(string)$entry['handle']]);
$this->interruptConsume();
}
$this->resolveEntries($entries);
} | [
"public",
"function",
"consume",
"(",
")",
"{",
"$",
"entries",
"=",
"$",
"this",
"->",
"readCompletedEntries",
"(",
")",
";",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"entry",
")",
"{",
"curl_multi_remove_handle",
"(",
"$",
"this",
"->",
"mh",
",",
... | Poll completed cURL entries, consume cURL queue and resolve them. | [
"Poll",
"completed",
"cURL",
"entries",
"consume",
"cURL",
"queue",
"and",
"resolve",
"them",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/AbstractScheduler.php#L62-L71 | train |
mpyw/co | src/Internal/AbstractScheduler.php | AbstractScheduler.resolveEntries | protected function resolveEntries(array $entries)
{
foreach ($entries as $entry) {
$deferred = $this->deferreds[(string)$entry['handle']];
unset($this->deferreds[(string)$entry['handle']]);
$entry['result'] === CURLE_OK
? $deferred->resolve(curl_multi_getcontent($entry['handle']))
: $deferred->reject(new CURLException(curl_error($entry['handle']), $entry['result'], $entry['handle']));
}
} | php | protected function resolveEntries(array $entries)
{
foreach ($entries as $entry) {
$deferred = $this->deferreds[(string)$entry['handle']];
unset($this->deferreds[(string)$entry['handle']]);
$entry['result'] === CURLE_OK
? $deferred->resolve(curl_multi_getcontent($entry['handle']))
: $deferred->reject(new CURLException(curl_error($entry['handle']), $entry['result'], $entry['handle']));
}
} | [
"protected",
"function",
"resolveEntries",
"(",
"array",
"$",
"entries",
")",
"{",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"entry",
")",
"{",
"$",
"deferred",
"=",
"$",
"this",
"->",
"deferreds",
"[",
"(",
"string",
")",
"$",
"entry",
"[",
"'handle'... | Resolve polled cURLs.
@param array $entries Polled cURL entries. | [
"Resolve",
"polled",
"cURLs",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/AbstractScheduler.php#L91-L100 | train |
mpyw/co | src/Internal/GeneratorContainer.php | GeneratorContainer.valid | public function valid()
{
try {
$this->g->current();
return $this->e === null && $this->g->valid() && $this->g->key() !== CoInterface::RETURN_WITH;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->e = $e;
return false;
} | php | public function valid()
{
try {
$this->g->current();
return $this->e === null && $this->g->valid() && $this->g->key() !== CoInterface::RETURN_WITH;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->e = $e;
return false;
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"g",
"->",
"current",
"(",
")",
";",
"return",
"$",
"this",
"->",
"e",
"===",
"null",
"&&",
"$",
"this",
"->",
"g",
"->",
"valid",
"(",
")",
"&&",
"$",
"this",
"->",
... | Return whether generator is actually working.
@return bool | [
"Return",
"whether",
"generator",
"is",
"actually",
"working",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/GeneratorContainer.php#L66-L74 | train |
mpyw/co | src/Internal/GeneratorContainer.php | GeneratorContainer.send | public function send($value)
{
$this->validateValidity();
try {
$this->g->send($value);
return;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->e = $e;
} | php | public function send($value)
{
$this->validateValidity();
try {
$this->g->send($value);
return;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->e = $e;
} | [
"public",
"function",
"send",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"validateValidity",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"g",
"->",
"send",
"(",
"$",
"value",
")",
";",
"return",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"... | Send value into generator.
@param mixed $value
@NOTE: This method returns nothing,
while original generator returns something. | [
"Send",
"value",
"into",
"generator",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/GeneratorContainer.php#L102-L110 | train |
mpyw/co | src/Internal/GeneratorContainer.php | GeneratorContainer.throw_ | public function throw_($e)
{
$this->validateValidity();
try {
$this->g->throw($e);
return;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->e = $e;
} | php | public function throw_($e)
{
$this->validateValidity();
try {
$this->g->throw($e);
return;
} catch (\Throwable $e) {} catch (\Exception $e) {}
$this->e = $e;
} | [
"public",
"function",
"throw_",
"(",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"validateValidity",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"g",
"->",
"throw",
"(",
"$",
"e",
")",
";",
"return",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
... | Throw exception into generator.
@param \Throwable|\Exception $e
@NOTE: This method returns nothing,
while original generator returns something. | [
"Throw",
"exception",
"into",
"generator",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/GeneratorContainer.php#L118-L126 | train |
mpyw/co | src/Internal/GeneratorContainer.php | GeneratorContainer.getReturnOrThrown | public function getReturnOrThrown()
{
$this->validateInvalidity();
if ($this->e === null && $this->g->valid() && !$this->valid()) {
return $this->g->current();
}
if ($this->e) {
return $this->e;
}
return method_exists($this->g, 'getReturn') ? $this->g->getReturn() : null;
} | php | public function getReturnOrThrown()
{
$this->validateInvalidity();
if ($this->e === null && $this->g->valid() && !$this->valid()) {
return $this->g->current();
}
if ($this->e) {
return $this->e;
}
return method_exists($this->g, 'getReturn') ? $this->g->getReturn() : null;
} | [
"public",
"function",
"getReturnOrThrown",
"(",
")",
"{",
"$",
"this",
"->",
"validateInvalidity",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"e",
"===",
"null",
"&&",
"$",
"this",
"->",
"g",
"->",
"valid",
"(",
")",
"&&",
"!",
"$",
"this",
"->",... | Return value that generator has returned or thrown.
@return mixed | [
"Return",
"value",
"that",
"generator",
"has",
"returned",
"or",
"thrown",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/GeneratorContainer.php#L141-L151 | train |
mpyw/co | src/Internal/ManualScheduler.php | ManualScheduler.addReserved | private function addReserved($ch, Deferred $deferred = null)
{
$this->queue[(string)$ch] = $ch;
$deferred && $this->deferreds[(string)$ch] = $deferred;
} | php | private function addReserved($ch, Deferred $deferred = null)
{
$this->queue[(string)$ch] = $ch;
$deferred && $this->deferreds[(string)$ch] = $deferred;
} | [
"private",
"function",
"addReserved",
"(",
"$",
"ch",
",",
"Deferred",
"$",
"deferred",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"queue",
"[",
"(",
"string",
")",
"$",
"ch",
"]",
"=",
"$",
"ch",
";",
"$",
"deferred",
"&&",
"$",
"this",
"->",
"de... | Push into queue.
@param resource $ch
@param Deferred $deferred | [
"Push",
"into",
"queue",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/ManualScheduler.php#L76-L80 | train |
mpyw/co | src/Internal/CoOption.php | CoOption.offsetGet | public function offsetGet($offset)
{
if (!isset($this->options[$offset])) {
throw new \DomainException('Undefined field: ' + $offset);
}
return $this->options[$offset];
} | php | public function offsetGet($offset)
{
if (!isset($this->options[$offset])) {
throw new \DomainException('Undefined field: ' + $offset);
}
return $this->options[$offset];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Undefined field: '",
"+",
"$",
"offset"... | Implemention of ArrayAccess.
@param mixed $offset
@return mixed | [
"Implemention",
"of",
"ArrayAccess",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/CoOption.php#L90-L96 | train |
mpyw/co | src/Internal/CoOption.php | CoOption.validateOptions | private static function validateOptions(array $options)
{
foreach ($options as $key => $value) {
if (!isset(self::$types[$key])) {
throw new \DomainException("Unknown option: $key");
}
if ($key === 'autoschedule' && !defined('CURLMOPT_MAX_TOTAL_CONNECTIONS')) {
throw new \OutOfBoundsException('"autoschedule" can be used only on PHP 7.0.7 or later.');
}
$validator = [__CLASS__, 'validate' . self::$types[$key]];
$options[$key] = $validator($key, $value);
}
return $options;
} | php | private static function validateOptions(array $options)
{
foreach ($options as $key => $value) {
if (!isset(self::$types[$key])) {
throw new \DomainException("Unknown option: $key");
}
if ($key === 'autoschedule' && !defined('CURLMOPT_MAX_TOTAL_CONNECTIONS')) {
throw new \OutOfBoundsException('"autoschedule" can be used only on PHP 7.0.7 or later.');
}
$validator = [__CLASS__, 'validate' . self::$types[$key]];
$options[$key] = $validator($key, $value);
}
return $options;
} | [
"private",
"static",
"function",
"validateOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"types",
"[",
"$",
"key",
"... | Validate options.
@param array $options
@return array | [
"Validate",
"options",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/CoOption.php#L124-L137 | train |
mpyw/co | src/Internal/CoOption.php | CoOption.validateBool | private static function validateBool($key, $value)
{
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN, [
'flags' => FILTER_NULL_ON_FAILURE,
]);
if ($value === null) {
throw new \InvalidArgumentException("Option[$key] must be boolean.");
}
return $value;
} | php | private static function validateBool($key, $value)
{
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN, [
'flags' => FILTER_NULL_ON_FAILURE,
]);
if ($value === null) {
throw new \InvalidArgumentException("Option[$key] must be boolean.");
}
return $value;
} | [
"private",
"static",
"function",
"validateBool",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_BOOLEAN",
",",
"[",
"'flags'",
"=>",
"FILTER_NULL_ON_FAILURE",
",",
"]",
")",
";",
"if"... | Validate bool value.
@param string $key
@param mixed $value
@throws InvalidArgumentException
@return bool | [
"Validate",
"bool",
"value",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/CoOption.php#L146-L155 | train |
mpyw/co | src/Internal/CoOption.php | CoOption.validateNaturalFloat | private static function validateNaturalFloat($key, $value)
{
$value = filter_var($value, FILTER_VALIDATE_FLOAT);
if ($value === false) {
throw new \InvalidArgumentException("Option[$key] must be float.");
}
if ($value < 0.0) {
throw new \DomainException("Option[$key] must be positive or zero.");
}
return $value;
} | php | private static function validateNaturalFloat($key, $value)
{
$value = filter_var($value, FILTER_VALIDATE_FLOAT);
if ($value === false) {
throw new \InvalidArgumentException("Option[$key] must be float.");
}
if ($value < 0.0) {
throw new \DomainException("Option[$key] must be positive or zero.");
}
return $value;
} | [
"private",
"static",
"function",
"validateNaturalFloat",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_FLOAT",
")",
";",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"throw",... | Validate natural float value.
@param string $key
@param mixed $value
@throws InvalidArgumentException
@return float | [
"Validate",
"natural",
"float",
"value",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/CoOption.php#L164-L174 | train |
mpyw/co | src/Internal/CoOption.php | CoOption.validateNaturalInt | private static function validateNaturalInt($key, $value)
{
$value = filter_var($value, FILTER_VALIDATE_INT);
if ($value === false) {
throw new \InvalidArgumentException("Option[$key] must be integer.");
}
if ($value < 0) {
throw new \DomainException("Option[$key] must be positive or zero.");
}
return $value;
} | php | private static function validateNaturalInt($key, $value)
{
$value = filter_var($value, FILTER_VALIDATE_INT);
if ($value === false) {
throw new \InvalidArgumentException("Option[$key] must be integer.");
}
if ($value < 0) {
throw new \DomainException("Option[$key] must be positive or zero.");
}
return $value;
} | [
"private",
"static",
"function",
"validateNaturalInt",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_INT",
")",
";",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"throw",
"... | Validate natural int value.
@param string $key
@param mixed $value
@throws InvalidArgumentException
@return int | [
"Validate",
"natural",
"int",
"value",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/CoOption.php#L183-L193 | train |
mpyw/co | src/Internal/YieldableUtils.php | YieldableUtils.getYieldables | public static function getYieldables($value, array $keylist = [], array &$runners = [])
{
$r = [];
if (!is_array($value)) {
if (TypeUtils::isCurl($value) || TypeUtils::isGeneratorContainer($value)) {
if (isset($runners[(string)$value])) {
throw new \DomainException('Duplicated cURL resource or Generator instance found.');
}
$r[(string)$value] = $runners[(string)$value] = [
'value' => $value,
'keylist' => $keylist,
];
}
return $r;
}
foreach ($value as $k => $v) {
$newlist = array_merge($keylist, [$k]);
$r = array_merge($r, self::getYieldables($v, $newlist, $runners));
}
return $r;
} | php | public static function getYieldables($value, array $keylist = [], array &$runners = [])
{
$r = [];
if (!is_array($value)) {
if (TypeUtils::isCurl($value) || TypeUtils::isGeneratorContainer($value)) {
if (isset($runners[(string)$value])) {
throw new \DomainException('Duplicated cURL resource or Generator instance found.');
}
$r[(string)$value] = $runners[(string)$value] = [
'value' => $value,
'keylist' => $keylist,
];
}
return $r;
}
foreach ($value as $k => $v) {
$newlist = array_merge($keylist, [$k]);
$r = array_merge($r, self::getYieldables($v, $newlist, $runners));
}
return $r;
} | [
"public",
"static",
"function",
"getYieldables",
"(",
"$",
"value",
",",
"array",
"$",
"keylist",
"=",
"[",
"]",
",",
"array",
"&",
"$",
"runners",
"=",
"[",
"]",
")",
"{",
"$",
"r",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"va... | Recursively search yieldable values.
Each entries are assoc those contain keys 'value' and 'keylist'.
value -> the value itself.
keylist -> position of the value. nests are represented as array values.
@param mixed $value Must be already normalized.
@param array $keylist Internally used.
@param array &$runners Running cURL or Generator identifiers.
@return array | [
"Recursively",
"search",
"yieldable",
"values",
".",
"Each",
"entries",
"are",
"assoc",
"those",
"contain",
"keys",
"value",
"and",
"keylist",
".",
"value",
"-",
">",
"the",
"value",
"itself",
".",
"keylist",
"-",
">",
"position",
"of",
"the",
"value",
"."... | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/YieldableUtils.php#L45-L65 | train |
mpyw/co | src/Internal/YieldableUtils.php | YieldableUtils.getApplier | public static function getApplier($yielded, array $yieldables, callable $next = null)
{
return function (array $results) use ($yielded, $yieldables, $next) {
foreach ($results as $hash => $resolved) {
$current = &$yielded;
foreach ($yieldables[$hash]['keylist'] as $key) {
$current = &$current[$key];
}
$current = $resolved;
unset($current);
}
return $next ? $next($yielded) : $yielded;
};
} | php | public static function getApplier($yielded, array $yieldables, callable $next = null)
{
return function (array $results) use ($yielded, $yieldables, $next) {
foreach ($results as $hash => $resolved) {
$current = &$yielded;
foreach ($yieldables[$hash]['keylist'] as $key) {
$current = &$current[$key];
}
$current = $resolved;
unset($current);
}
return $next ? $next($yielded) : $yielded;
};
} | [
"public",
"static",
"function",
"getApplier",
"(",
"$",
"yielded",
",",
"array",
"$",
"yieldables",
",",
"callable",
"$",
"next",
"=",
"null",
")",
"{",
"return",
"function",
"(",
"array",
"$",
"results",
")",
"use",
"(",
"$",
"yielded",
",",
"$",
"yie... | Return function that apply changes in yieldables.
@param mixed $yielded
@param array $yieldables
@param callable|null $next
@return mixed | [
"Return",
"function",
"that",
"apply",
"changes",
"in",
"yieldables",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/YieldableUtils.php#L74-L87 | train |
mpyw/co | src/Internal/YieldableUtils.php | YieldableUtils.safePromise | public static function safePromise(PromiseInterface $promise)
{
return $promise->then(null, function ($value) {
if (TypeUtils::isFatalThrowable($value)) {
throw $value;
}
return $value;
});
} | php | public static function safePromise(PromiseInterface $promise)
{
return $promise->then(null, function ($value) {
if (TypeUtils::isFatalThrowable($value)) {
throw $value;
}
return $value;
});
} | [
"public",
"static",
"function",
"safePromise",
"(",
"PromiseInterface",
"$",
"promise",
")",
"{",
"return",
"$",
"promise",
"->",
"then",
"(",
"null",
",",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"TypeUtils",
"::",
"isFatalThrowable",
"(",
"$",... | Return Promise that absorbs rejects, excluding fatal Throwable.
@param PromiseInterface $promise
@return PromiseInterface | [
"Return",
"Promise",
"that",
"absorbs",
"rejects",
"excluding",
"fatal",
"Throwable",
"."
] | 1ab101b8ef5feb634a028d385aadeba23da18dca | https://github.com/mpyw/co/blob/1ab101b8ef5feb634a028d385aadeba23da18dca/src/Internal/YieldableUtils.php#L94-L102 | train |
sitepoint-editors/Container | src/Container.php | Container.createService | private function createService($name)
{
$entry = &$this->services[$name];
if (!is_array($entry) || !isset($entry['class'])) {
throw new ContainerException($name.' service entry must be an array containing a \'class\' key');
} elseif (!class_exists($entry['class'])) {
throw new ContainerException($name.' service class does not exist: '.$entry['class']);
} elseif (isset($entry['lock'])) {
throw new ContainerException($name.' contains circular reference');
}
$entry['lock'] = true;
$arguments = isset($entry['arguments']) ? $this->resolveArguments($entry['arguments']) : [];
$reflector = new \ReflectionClass($entry['class']);
$service = $reflector->newInstanceArgs($arguments);
if (isset($entry['calls'])) {
$this->initializeService($service, $name, $entry['calls']);
}
return $service;
} | php | private function createService($name)
{
$entry = &$this->services[$name];
if (!is_array($entry) || !isset($entry['class'])) {
throw new ContainerException($name.' service entry must be an array containing a \'class\' key');
} elseif (!class_exists($entry['class'])) {
throw new ContainerException($name.' service class does not exist: '.$entry['class']);
} elseif (isset($entry['lock'])) {
throw new ContainerException($name.' contains circular reference');
}
$entry['lock'] = true;
$arguments = isset($entry['arguments']) ? $this->resolveArguments($entry['arguments']) : [];
$reflector = new \ReflectionClass($entry['class']);
$service = $reflector->newInstanceArgs($arguments);
if (isset($entry['calls'])) {
$this->initializeService($service, $name, $entry['calls']);
}
return $service;
} | [
"private",
"function",
"createService",
"(",
"$",
"name",
")",
"{",
"$",
"entry",
"=",
"&",
"$",
"this",
"->",
"services",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"entry",
")",
"||",
"!",
"isset",
"(",
"$",
"entry",
"[",... | Attempt to create a service.
@param string $name The service name.
@return mixed The created service.
@throws ContainerException On failure. | [
"Attempt",
"to",
"create",
"a",
"service",
"."
] | 03a26a6a8014c21faaca697cbab17d4e5c8d7f64 | https://github.com/sitepoint-editors/Container/blob/03a26a6a8014c21faaca697cbab17d4e5c8d7f64/src/Container.php#L121-L145 | train |
sitepoint-editors/Container | src/Container.php | Container.resolveArguments | private function resolveArguments(array $argumentDefinitions)
{
$arguments = [];
foreach ($argumentDefinitions as $argumentDefinition) {
if ($argumentDefinition instanceof ServiceReference) {
$argumentServiceName = $argumentDefinition->getName();
$arguments[] = $this->get($argumentServiceName);
} elseif ($argumentDefinition instanceof ParameterReference) {
$argumentParameterName = $argumentDefinition->getName();
$arguments[] = $this->getParameter($argumentParameterName);
} else {
$arguments[] = $argumentDefinition;
}
}
return $arguments;
} | php | private function resolveArguments(array $argumentDefinitions)
{
$arguments = [];
foreach ($argumentDefinitions as $argumentDefinition) {
if ($argumentDefinition instanceof ServiceReference) {
$argumentServiceName = $argumentDefinition->getName();
$arguments[] = $this->get($argumentServiceName);
} elseif ($argumentDefinition instanceof ParameterReference) {
$argumentParameterName = $argumentDefinition->getName();
$arguments[] = $this->getParameter($argumentParameterName);
} else {
$arguments[] = $argumentDefinition;
}
}
return $arguments;
} | [
"private",
"function",
"resolveArguments",
"(",
"array",
"$",
"argumentDefinitions",
")",
"{",
"$",
"arguments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"argumentDefinitions",
"as",
"$",
"argumentDefinition",
")",
"{",
"if",
"(",
"$",
"argumentDefinition",
"i... | Resolve argument definitions into an array of arguments.
@param array $argumentDefinitions The service arguments definition.
@return array The service constructor arguments.
@throws ContainerException On failure. | [
"Resolve",
"argument",
"definitions",
"into",
"an",
"array",
"of",
"arguments",
"."
] | 03a26a6a8014c21faaca697cbab17d4e5c8d7f64 | https://github.com/sitepoint-editors/Container/blob/03a26a6a8014c21faaca697cbab17d4e5c8d7f64/src/Container.php#L156-L175 | train |
sitepoint-editors/Container | src/Container.php | Container.initializeService | private function initializeService($service, $name, array $callDefinitions)
{
foreach ($callDefinitions as $callDefinition) {
if (!is_array($callDefinition) || !isset($callDefinition['method'])) {
throw new ContainerException($name.' service calls must be arrays containing a \'method\' key');
} elseif (!is_callable([$service, $callDefinition['method']])) {
throw new ContainerException($name.' service asks for call to uncallable method: '.$callDefinition['method']);
}
$arguments = isset($callDefinition['arguments']) ? $this->resolveArguments($callDefinition['arguments']) : [];
call_user_func_array([$service, $callDefinition['method']], $arguments);
}
} | php | private function initializeService($service, $name, array $callDefinitions)
{
foreach ($callDefinitions as $callDefinition) {
if (!is_array($callDefinition) || !isset($callDefinition['method'])) {
throw new ContainerException($name.' service calls must be arrays containing a \'method\' key');
} elseif (!is_callable([$service, $callDefinition['method']])) {
throw new ContainerException($name.' service asks for call to uncallable method: '.$callDefinition['method']);
}
$arguments = isset($callDefinition['arguments']) ? $this->resolveArguments($callDefinition['arguments']) : [];
call_user_func_array([$service, $callDefinition['method']], $arguments);
}
} | [
"private",
"function",
"initializeService",
"(",
"$",
"service",
",",
"$",
"name",
",",
"array",
"$",
"callDefinitions",
")",
"{",
"foreach",
"(",
"$",
"callDefinitions",
"as",
"$",
"callDefinition",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"callDef... | Initialize a service using the call definitions.
@param object $service The service.
@param string $name The service name.
@param array $callDefinitions The service calls definition.
@throws ContainerException On failure. | [
"Initialize",
"a",
"service",
"using",
"the",
"call",
"definitions",
"."
] | 03a26a6a8014c21faaca697cbab17d4e5c8d7f64 | https://github.com/sitepoint-editors/Container/blob/03a26a6a8014c21faaca697cbab17d4e5c8d7f64/src/Container.php#L186-L199 | train |
jarektkaczyk/eloquence-mutable | src/Mutator/Mutator.php | Mutator.mutate | public function mutate($value, $callables)
{
if (!is_array($callables)) {
$callables = explode('|', $callables);
}
foreach ($callables as $callable) {
list($callable, $args) = $this->parse(trim($callable));
$value = call_user_func_array($callable, array_merge([$value], $args));
}
return $value;
} | php | public function mutate($value, $callables)
{
if (!is_array($callables)) {
$callables = explode('|', $callables);
}
foreach ($callables as $callable) {
list($callable, $args) = $this->parse(trim($callable));
$value = call_user_func_array($callable, array_merge([$value], $args));
}
return $value;
} | [
"public",
"function",
"mutate",
"(",
"$",
"value",
",",
"$",
"callables",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"callables",
")",
")",
"{",
"$",
"callables",
"=",
"explode",
"(",
"'|'",
",",
"$",
"callables",
")",
";",
"}",
"foreach",
"("... | Mutate value using provided methods.
@param mixed $value
@param string|array $callables
@return mixed
@throws \LogicException | [
"Mutate",
"value",
"using",
"provided",
"methods",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutator/Mutator.php#L24-L37 | train |
jarektkaczyk/eloquence-mutable | src/Mutator/Mutator.php | Mutator.parse | protected function parse($callable)
{
list($callable, $args) = $this->parseArgs($callable);
if ($this->isClassMethod($callable)) {
$callable = $this->parseClassMethod($callable);
} elseif ($this->isMutatorMethod($callable)) {
$callable = [$this, $callable];
} elseif (!function_exists($callable)) {
throw new InvalidCallableException("Function [{$callable}] not found.");
}
return [$callable, $args];
} | php | protected function parse($callable)
{
list($callable, $args) = $this->parseArgs($callable);
if ($this->isClassMethod($callable)) {
$callable = $this->parseClassMethod($callable);
} elseif ($this->isMutatorMethod($callable)) {
$callable = [$this, $callable];
} elseif (!function_exists($callable)) {
throw new InvalidCallableException("Function [{$callable}] not found.");
}
return [$callable, $args];
} | [
"protected",
"function",
"parse",
"(",
"$",
"callable",
")",
"{",
"list",
"(",
"$",
"callable",
",",
"$",
"args",
")",
"=",
"$",
"this",
"->",
"parseArgs",
"(",
"$",
"callable",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isClassMethod",
"(",
"$",
"ca... | Parse provided mutator functions.
@param string $callable
@return array
@throws \Sofa\Eloquence\Mutator\InvalidCallableException | [
"Parse",
"provided",
"mutator",
"functions",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutator/Mutator.php#L47-L60 | train |
jarektkaczyk/eloquence-mutable | src/Mutator/Mutator.php | Mutator.parseArgs | protected function parseArgs($callable)
{
$args = [];
if (strpos($callable, ':') !== false) {
list($callable, $argsString) = explode(':', $callable);
$args = explode(',', $argsString);
}
return [$callable, $args];
} | php | protected function parseArgs($callable)
{
$args = [];
if (strpos($callable, ':') !== false) {
list($callable, $argsString) = explode(':', $callable);
$args = explode(',', $argsString);
}
return [$callable, $args];
} | [
"protected",
"function",
"parseArgs",
"(",
"$",
"callable",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"callable",
",",
"':'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"callable",
",",
"$",
"argsString",
")",
... | Split provided string into callable and arguments.
@param string $callable
@return array | [
"Split",
"provided",
"string",
"into",
"callable",
"and",
"arguments",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutator/Mutator.php#L90-L101 | train |
jarektkaczyk/eloquence-mutable | src/Mutator/Mutator.php | Mutator.parseClassMethod | protected function parseClassMethod($userCallable)
{
list($class) = explode('@', $userCallable);
$callable = str_replace('@', '::', $userCallable);
try {
$method = new ReflectionMethod($callable);
$class = new ReflectionClass($class);
} catch (ReflectionException $e) {
throw new InvalidCallableException($e->getMessage());
}
return ($method->isStatic()) ? $callable : $this->getInstanceMethod($class, $method);
} | php | protected function parseClassMethod($userCallable)
{
list($class) = explode('@', $userCallable);
$callable = str_replace('@', '::', $userCallable);
try {
$method = new ReflectionMethod($callable);
$class = new ReflectionClass($class);
} catch (ReflectionException $e) {
throw new InvalidCallableException($e->getMessage());
}
return ($method->isStatic()) ? $callable : $this->getInstanceMethod($class, $method);
} | [
"protected",
"function",
"parseClassMethod",
"(",
"$",
"userCallable",
")",
"{",
"list",
"(",
"$",
"class",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"userCallable",
")",
";",
"$",
"callable",
"=",
"str_replace",
"(",
"'@'",
",",
"'::'",
",",
"$",
"us... | Extract and validate class method.
@param string $userCallable
@return callable
@throws \Sofa\Eloquence\Mutator\InvalidCallableException | [
"Extract",
"and",
"validate",
"class",
"method",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutator/Mutator.php#L111-L126 | train |
jarektkaczyk/eloquence-mutable | src/Mutator/Mutator.php | Mutator.getInstanceMethod | protected function getInstanceMethod(ReflectionClass $class, ReflectionMethod $method)
{
if (!$method->isPublic()) {
throw new InvalidCallableException("Instance method [{$class}@{$method->getName()}] is not public.");
}
if (!$this->canInstantiate($class)) {
throw new InvalidCallableException("Can't instantiate class [{$class->getName()}].");
}
return [$class->newInstance(), $method->getName()];
} | php | protected function getInstanceMethod(ReflectionClass $class, ReflectionMethod $method)
{
if (!$method->isPublic()) {
throw new InvalidCallableException("Instance method [{$class}@{$method->getName()}] is not public.");
}
if (!$this->canInstantiate($class)) {
throw new InvalidCallableException("Can't instantiate class [{$class->getName()}].");
}
return [$class->newInstance(), $method->getName()];
} | [
"protected",
"function",
"getInstanceMethod",
"(",
"ReflectionClass",
"$",
"class",
",",
"ReflectionMethod",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidCallableException",
"(",
"\"Insta... | Get instance callable.
@param \ReflectionMethod $method
@return callable
@throws \Sofa\Eloquence\Mutator\InvalidCallableException | [
"Get",
"instance",
"callable",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutator/Mutator.php#L136-L147 | train |
jarektkaczyk/eloquence-mutable | src/Mutator/Mutator.php | Mutator.canInstantiate | protected function canInstantiate(ReflectionClass $class)
{
if (!$class->isInstantiable()) {
return false;
}
$constructor = $class->getConstructor();
return is_null($constructor) || 0 === $constructor->getNumberOfRequiredParameters();
} | php | protected function canInstantiate(ReflectionClass $class)
{
if (!$class->isInstantiable()) {
return false;
}
$constructor = $class->getConstructor();
return is_null($constructor) || 0 === $constructor->getNumberOfRequiredParameters();
} | [
"protected",
"function",
"canInstantiate",
"(",
"ReflectionClass",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"$",
"class",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"constructor",
"=",
"$",
"class",
"->",
"getConstructor",... | Determine whether instance can be instantiated.
@param \ReflectionClass $class
@return boolean | [
"Determine",
"whether",
"instance",
"can",
"be",
"instantiated",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutator/Mutator.php#L155-L164 | train |
jarektkaczyk/eloquence-mutable | src/Mutable.php | Mutable.bootMutable | public static function bootMutable()
{
if (!isset(static::$attributeMutator)) {
if (function_exists('app') && app()->bound('eloquence.mutator')) {
static::setAttributeMutator(app('eloquence.mutator'));
} else {
static::setAttributeMutator(new Mutator);
}
}
$hooks = new Hooks;
foreach (['setAttribute', 'getAttribute', 'toArray'] as $method) {
static::hook($method, $hooks->{$method}());
}
} | php | public static function bootMutable()
{
if (!isset(static::$attributeMutator)) {
if (function_exists('app') && app()->bound('eloquence.mutator')) {
static::setAttributeMutator(app('eloquence.mutator'));
} else {
static::setAttributeMutator(new Mutator);
}
}
$hooks = new Hooks;
foreach (['setAttribute', 'getAttribute', 'toArray'] as $method) {
static::hook($method, $hooks->{$method}());
}
} | [
"public",
"static",
"function",
"bootMutable",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"attributeMutator",
")",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'app'",
")",
"&&",
"app",
"(",
")",
"->",
"bound",
"(",
"'eloquence.... | Register hooks for the trait.
@codeCoverageIgnore
@return void | [
"Register",
"hooks",
"for",
"the",
"trait",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutable.php#L29-L44 | train |
jarektkaczyk/eloquence-mutable | src/Mutable.php | Mutable.mutableAttributesToArray | protected function mutableAttributesToArray(array $attributes)
{
foreach ($attributes as $key => $value) {
if ($this->hasGetterMutator($key)) {
$attributes[$key] = $this->mutableMutate($key, $value, 'getter');
}
}
return $attributes;
} | php | protected function mutableAttributesToArray(array $attributes)
{
foreach ($attributes as $key => $value) {
if ($this->hasGetterMutator($key)) {
$attributes[$key] = $this->mutableMutate($key, $value, 'getter');
}
}
return $attributes;
} | [
"protected",
"function",
"mutableAttributesToArray",
"(",
"array",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasGetterMutator",
"(",
"$",
"key",
")",
")"... | Mutate mutable attributes for array conversion.
@param array $attributes
@return array | [
"Mutate",
"mutable",
"attributes",
"for",
"array",
"conversion",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutable.php#L52-L61 | train |
jarektkaczyk/eloquence-mutable | src/Mutable.php | Mutable.mutableMutate | protected function mutableMutate($key, $value, $dir)
{
$mutators = $this->getMutatorsForAttribute($key, $dir);
return static::$attributeMutator->mutate($value, $mutators);
} | php | protected function mutableMutate($key, $value, $dir)
{
$mutators = $this->getMutatorsForAttribute($key, $dir);
return static::$attributeMutator->mutate($value, $mutators);
} | [
"protected",
"function",
"mutableMutate",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"dir",
")",
"{",
"$",
"mutators",
"=",
"$",
"this",
"->",
"getMutatorsForAttribute",
"(",
"$",
"key",
",",
"$",
"dir",
")",
";",
"return",
"static",
"::",
"$",
"a... | Mutate the attribute.
@param string $key
@param string $value
@param string $dir
@return mixed | [
"Mutate",
"the",
"attribute",
"."
] | c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69 | https://github.com/jarektkaczyk/eloquence-mutable/blob/c2d361e8b2a7ae6aaa2324b78b401e944ef3bc69/src/Mutable.php#L93-L98 | train |
austinhyde/IniParser | src/IniParser.php | IniParser.parse | public function parse($file = null) {
if ($file !== null) {
$this->setFile($file);
}
if (empty($this->file)) {
throw new LogicException("Need a file to parse.");
}
$simple_parsed = parse_ini_file($this->file, true);
$inheritance_parsed = $this->parseSections($simple_parsed);
return $this->parseKeys($inheritance_parsed);
} | php | public function parse($file = null) {
if ($file !== null) {
$this->setFile($file);
}
if (empty($this->file)) {
throw new LogicException("Need a file to parse.");
}
$simple_parsed = parse_ini_file($this->file, true);
$inheritance_parsed = $this->parseSections($simple_parsed);
return $this->parseKeys($inheritance_parsed);
} | [
"public",
"function",
"parse",
"(",
"$",
"file",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"file",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setFile",
"(",
"$",
"file",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"file",
")",
"... | Parses an INI file
@param string $file
@return array | [
"Parses",
"an",
"INI",
"file"
] | 3b5a925ac99619d198d8ff93958913ca3311f266 | https://github.com/austinhyde/IniParser/blob/3b5a925ac99619d198d8ff93958913ca3311f266/src/IniParser.php#L82-L93 | train |
austinhyde/IniParser | src/IniParser.php | IniParser.process | public function process($src) {
$simple_parsed = parse_ini_string($src, true);
$inheritance_parsed = $this->parseSections($simple_parsed);
return $this->parseKeys($inheritance_parsed);
} | php | public function process($src) {
$simple_parsed = parse_ini_string($src, true);
$inheritance_parsed = $this->parseSections($simple_parsed);
return $this->parseKeys($inheritance_parsed);
} | [
"public",
"function",
"process",
"(",
"$",
"src",
")",
"{",
"$",
"simple_parsed",
"=",
"parse_ini_string",
"(",
"$",
"src",
",",
"true",
")",
";",
"$",
"inheritance_parsed",
"=",
"$",
"this",
"->",
"parseSections",
"(",
"$",
"simple_parsed",
")",
";",
"r... | Parses a string with INI contents
@param string $src
@return array | [
"Parses",
"a",
"string",
"with",
"INI",
"contents"
] | 3b5a925ac99619d198d8ff93958913ca3311f266 | https://github.com/austinhyde/IniParser/blob/3b5a925ac99619d198d8ff93958913ca3311f266/src/IniParser.php#L102-L106 | train |
austinhyde/IniParser | src/IniParser.php | IniParser.parseSections | private function parseSections(array $simple_parsed) {
// do an initial pass to gather section names
$sections = array();
$globals = array();
foreach ($simple_parsed as $k => $v) {
if (is_array($v)) {
// $k is a section name
$sections[$k] = $v;
} else {
$globals[$k] = $v;
}
}
// now for each section, see if it uses inheritance
$output_sections = array();
foreach ($sections as $k => $v) {
$sects = array_map('trim', array_reverse(explode(':', $k)));
$root = array_pop($sects);
$arr = $v;
foreach ($sects as $s) {
if ($s === '^') {
$arr = array_merge($globals, $arr);
} elseif (array_key_exists($s, $output_sections)) {
$arr = array_merge($output_sections[$s], $arr);
} elseif (array_key_exists($s, $sections)) {
$arr = array_merge($sections[$s], $arr);
} else {
throw new UnexpectedValueException("IniParser: In file '{$this->file}', section '{$root}': Cannot inherit from unknown section '{$s}'");
}
}
if ($this->include_original_sections) {
$output_sections[$k] = $v;
}
$output_sections[$root] = $arr;
}
return $globals + $output_sections;
} | php | private function parseSections(array $simple_parsed) {
// do an initial pass to gather section names
$sections = array();
$globals = array();
foreach ($simple_parsed as $k => $v) {
if (is_array($v)) {
// $k is a section name
$sections[$k] = $v;
} else {
$globals[$k] = $v;
}
}
// now for each section, see if it uses inheritance
$output_sections = array();
foreach ($sections as $k => $v) {
$sects = array_map('trim', array_reverse(explode(':', $k)));
$root = array_pop($sects);
$arr = $v;
foreach ($sects as $s) {
if ($s === '^') {
$arr = array_merge($globals, $arr);
} elseif (array_key_exists($s, $output_sections)) {
$arr = array_merge($output_sections[$s], $arr);
} elseif (array_key_exists($s, $sections)) {
$arr = array_merge($sections[$s], $arr);
} else {
throw new UnexpectedValueException("IniParser: In file '{$this->file}', section '{$root}': Cannot inherit from unknown section '{$s}'");
}
}
if ($this->include_original_sections) {
$output_sections[$k] = $v;
}
$output_sections[$root] = $arr;
}
return $globals + $output_sections;
} | [
"private",
"function",
"parseSections",
"(",
"array",
"$",
"simple_parsed",
")",
"{",
"// do an initial pass to gather section names",
"$",
"sections",
"=",
"array",
"(",
")",
";",
"$",
"globals",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"simple_parsed"... | Parse sections and inheritance.
@param array $simple_parsed
@return array Parsed sections | [
"Parse",
"sections",
"and",
"inheritance",
"."
] | 3b5a925ac99619d198d8ff93958913ca3311f266 | https://github.com/austinhyde/IniParser/blob/3b5a925ac99619d198d8ff93958913ca3311f266/src/IniParser.php#L127-L166 | train |
austinhyde/IniParser | src/IniParser.php | IniParser.parseValue | protected function parseValue($value) {
switch ($this->array_literals_behavior) {
case self::PARSE_JSON:
if (in_array(substr($value, 0, 1), array('[', '{')) && in_array(substr($value, -1), array(']', '}'))) {
if (defined('JSON_BIGINT_AS_STRING')) {
$output = json_decode($value, true, 512, JSON_BIGINT_AS_STRING);
} else {
$output = json_decode($value, true);
}
if ($output !== NULL) {
return $output;
}
}
// fallthrough
// try regex parser for simple estructures not JSON-compatible (ex: colors = [blue, green, red])
case self::PARSE_SIMPLE:
// if the value looks like [a,b,c,...], interpret as array
if (preg_match('/^\[\s*.*?(?:\s*,\s*.*?)*\s*\]$/', trim($value))) {
return array_map('trim', explode(',', trim(trim($value), '[]')));
}
break;
}
return $value;
} | php | protected function parseValue($value) {
switch ($this->array_literals_behavior) {
case self::PARSE_JSON:
if (in_array(substr($value, 0, 1), array('[', '{')) && in_array(substr($value, -1), array(']', '}'))) {
if (defined('JSON_BIGINT_AS_STRING')) {
$output = json_decode($value, true, 512, JSON_BIGINT_AS_STRING);
} else {
$output = json_decode($value, true);
}
if ($output !== NULL) {
return $output;
}
}
// fallthrough
// try regex parser for simple estructures not JSON-compatible (ex: colors = [blue, green, red])
case self::PARSE_SIMPLE:
// if the value looks like [a,b,c,...], interpret as array
if (preg_match('/^\[\s*.*?(?:\s*,\s*.*?)*\s*\]$/', trim($value))) {
return array_map('trim', explode(',', trim(trim($value), '[]')));
}
break;
}
return $value;
} | [
"protected",
"function",
"parseValue",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"array_literals_behavior",
")",
"{",
"case",
"self",
"::",
"PARSE_JSON",
":",
"if",
"(",
"in_array",
"(",
"substr",
"(",
"$",
"value",
",",
"0",
",",
... | Parses and formats the value in a key-value pair
@param string $value
@return mixed | [
"Parses",
"and",
"formats",
"the",
"value",
"in",
"a",
"key",
"-",
"value",
"pair"
] | 3b5a925ac99619d198d8ff93958913ca3311f266 | https://github.com/austinhyde/IniParser/blob/3b5a925ac99619d198d8ff93958913ca3311f266/src/IniParser.php#L238-L262 | train |
awjudd/l4-feed-reader | src/FeedReader.php | FeedReader.read | public function read($url, $configuration = 'default')
{
// Setup the object
$sp = new SimplePie();
// Configure it
if(($cache = $this->setup_cache_directory($configuration)) !== false)
{
// Enable caching, and set the folder
$sp->enable_cache(true);
$sp->set_cache_location($cache);
$sp->set_cache_duration($this->read_config($configuration, 'cache.duration', 3600));
}
else
{
// Disable caching
$sp->enable_cache(false);
}
// Whether or not to force the feed reading
$sp->force_feed($this->read_config($configuration, 'force-feed', false));
// Should we be ordering the feed by date?
$sp->enable_order_by_date($this->read_config($configuration, 'order-by-date', false));
// Set the feed URL
$sp->set_feed_url($url);
// Grab it
$sp->init();
// We are done, so return it
return $sp;
} | php | public function read($url, $configuration = 'default')
{
// Setup the object
$sp = new SimplePie();
// Configure it
if(($cache = $this->setup_cache_directory($configuration)) !== false)
{
// Enable caching, and set the folder
$sp->enable_cache(true);
$sp->set_cache_location($cache);
$sp->set_cache_duration($this->read_config($configuration, 'cache.duration', 3600));
}
else
{
// Disable caching
$sp->enable_cache(false);
}
// Whether or not to force the feed reading
$sp->force_feed($this->read_config($configuration, 'force-feed', false));
// Should we be ordering the feed by date?
$sp->enable_order_by_date($this->read_config($configuration, 'order-by-date', false));
// Set the feed URL
$sp->set_feed_url($url);
// Grab it
$sp->init();
// We are done, so return it
return $sp;
} | [
"public",
"function",
"read",
"(",
"$",
"url",
",",
"$",
"configuration",
"=",
"'default'",
")",
"{",
"// Setup the object",
"$",
"sp",
"=",
"new",
"SimplePie",
"(",
")",
";",
"// Configure it",
"if",
"(",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"se... | Used to parse an RSS feed.
@return \SimplePie | [
"Used",
"to",
"parse",
"an",
"RSS",
"feed",
"."
] | 83c67b4140680192df93ae47fa88ff39414e40fd | https://github.com/awjudd/l4-feed-reader/blob/83c67b4140680192df93ae47fa88ff39414e40fd/src/FeedReader.php#L19-L52 | train |
awjudd/l4-feed-reader | src/FeedReader.php | FeedReader.setup_cache_directory | private function setup_cache_directory($configuration)
{
// Check if caching is enabled
$cache_enabled = $this->read_config($configuration, 'cache.enabled', false);
// Is caching enabled?
if(!$cache_enabled)
{
// It is disabled, so skip it
return false;
}
// Grab the cache location
$cache_location = storage_path($this->read_config($configuration, 'cache.location', 'rss-feeds'));
// Is the last character a slash?
if(substr($cache_location, -1) != DIRECTORY_SEPARATOR)
{
// Add in the slash at the end
$cache_location .= DIRECTORY_SEPARATOR;
}
// Check if the folder is available
if(!file_exists($cache_location))
{
// It didn't, so make it
mkdir($cache_location, 0777);
// Also add in a .gitignore file
file_put_contents($cache_location . '.gitignore', '!.gitignore' . PHP_EOL . '*');
}
return $cache_location;
} | php | private function setup_cache_directory($configuration)
{
// Check if caching is enabled
$cache_enabled = $this->read_config($configuration, 'cache.enabled', false);
// Is caching enabled?
if(!$cache_enabled)
{
// It is disabled, so skip it
return false;
}
// Grab the cache location
$cache_location = storage_path($this->read_config($configuration, 'cache.location', 'rss-feeds'));
// Is the last character a slash?
if(substr($cache_location, -1) != DIRECTORY_SEPARATOR)
{
// Add in the slash at the end
$cache_location .= DIRECTORY_SEPARATOR;
}
// Check if the folder is available
if(!file_exists($cache_location))
{
// It didn't, so make it
mkdir($cache_location, 0777);
// Also add in a .gitignore file
file_put_contents($cache_location . '.gitignore', '!.gitignore' . PHP_EOL . '*');
}
return $cache_location;
} | [
"private",
"function",
"setup_cache_directory",
"(",
"$",
"configuration",
")",
"{",
"// Check if caching is enabled",
"$",
"cache_enabled",
"=",
"$",
"this",
"->",
"read_config",
"(",
"$",
"configuration",
",",
"'cache.enabled'",
",",
"false",
")",
";",
"// Is cach... | Used in order to setup the cache directory for future use.
@param string The configuration to use
@return string The folder that is being cached to | [
"Used",
"in",
"order",
"to",
"setup",
"the",
"cache",
"directory",
"for",
"future",
"use",
"."
] | 83c67b4140680192df93ae47fa88ff39414e40fd | https://github.com/awjudd/l4-feed-reader/blob/83c67b4140680192df93ae47fa88ff39414e40fd/src/FeedReader.php#L60-L93 | train |
gliterd/flysystem-backblaze | src/BackblazeAdapter.php | BackblazeAdapter.getFileInfo | protected function getFileInfo($file)
{
$normalized = [
'type' => 'file',
'path' => $file->getName(),
'timestamp' => substr($file->getUploadTimestamp(), 0, -3),
'size' => $file->getSize(),
];
return $normalized;
} | php | protected function getFileInfo($file)
{
$normalized = [
'type' => 'file',
'path' => $file->getName(),
'timestamp' => substr($file->getUploadTimestamp(), 0, -3),
'size' => $file->getSize(),
];
return $normalized;
} | [
"protected",
"function",
"getFileInfo",
"(",
"$",
"file",
")",
"{",
"$",
"normalized",
"=",
"[",
"'type'",
"=>",
"'file'",
",",
"'path'",
"=>",
"$",
"file",
"->",
"getName",
"(",
")",
",",
"'timestamp'",
"=>",
"substr",
"(",
"$",
"file",
"->",
"getUplo... | Get file info.
@param $file
@return array | [
"Get",
"file",
"info",
"."
] | 42549be7b3e6f372c824896ccd1d901052cb6d8c | https://github.com/gliterd/flysystem-backblaze/blob/42549be7b3e6f372c824896ccd1d901052cb6d8c/src/BackblazeAdapter.php#L255-L265 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.generatePreSignedUrl | public function generatePreSignedUrl($bucketName, $key, $options = array())
{
list(
$config,
$headers,
$params,
$signOptions
) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::HEADERS,
BosOptions::PARAMS,
BosOptions::SIGN_OPTIONS
);
if(is_null($config)) {
$config = $this->config;
} else {
$config = array_merge($this->config, $config);
}
if(is_null($params)) {
$params = array();
}
if(is_null($headers)) {
$headers = array();
}
$path = $this->getPath($bucketName, $key);
list($hostUrl, $hostHeader) =
HttpUtils::parseEndpointFromConfig($config);
$headers[HttpHeaders::HOST] = $hostHeader;
$auth = $this->signer->sign(
$config[BceClientConfigOptions::CREDENTIALS],
HttpMethod::GET,
$path,
$headers,
$params,
$signOptions
);
$params['authorization'] = $auth;
$url = $hostUrl . HttpUtils::urlEncodeExceptSlash($path);
$queryString = HttpUtils::getCanonicalQueryString($params, false);
if ($queryString !== '') {
$url .= "?$queryString";
}
return $url;
} | php | public function generatePreSignedUrl($bucketName, $key, $options = array())
{
list(
$config,
$headers,
$params,
$signOptions
) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::HEADERS,
BosOptions::PARAMS,
BosOptions::SIGN_OPTIONS
);
if(is_null($config)) {
$config = $this->config;
} else {
$config = array_merge($this->config, $config);
}
if(is_null($params)) {
$params = array();
}
if(is_null($headers)) {
$headers = array();
}
$path = $this->getPath($bucketName, $key);
list($hostUrl, $hostHeader) =
HttpUtils::parseEndpointFromConfig($config);
$headers[HttpHeaders::HOST] = $hostHeader;
$auth = $this->signer->sign(
$config[BceClientConfigOptions::CREDENTIALS],
HttpMethod::GET,
$path,
$headers,
$params,
$signOptions
);
$params['authorization'] = $auth;
$url = $hostUrl . HttpUtils::urlEncodeExceptSlash($path);
$queryString = HttpUtils::getCanonicalQueryString($params, false);
if ($queryString !== '') {
$url .= "?$queryString";
}
return $url;
} | [
"public",
"function",
"generatePreSignedUrl",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"headers",
",",
"$",
"params",
",",
"$",
"signOptions",
")",
"=",
"$",... | Get an authorization url with expire time
@param string $bucketName The bucket name.
@param string $object_name The object path.
@param number $timestamp
@param number $expiration_in_seconds The valid time in seconds.
@param mixed $options The extra Http request headers or params.
@return string | [
"Get",
"an",
"authorization",
"url",
"with",
"expire",
"time"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L74-L122 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.listBuckets | public function listBuckets($options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config
)
);
} | php | public function listBuckets($options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config
)
);
} | [
"public",
"function",
"listBuckets",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
"::",
"CONFIG",
")",
";",
"return",
"$",
"thi... | List buckets of user.
@param array $options Supported options:
<ul>
<li>config: The optional bce configuration, which will overwrite
the default client configuration that was passed in constructor.
</li>
</ul>
@return object the server response. | [
"List",
"buckets",
"of",
"user",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L135-L145 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.createBucket | public function createBucket($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName
)
);
} | php | public function createBucket($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName
)
);
} | [
"public",
"function",
"createBucket",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
"::",
"CONFIG",
")",
... | Create a new bucket.
@param string $bucketName The bucket name.
@param array $options Supported options:
<ul>
<li>config: The optional bce configuration, which will overwrite
the default client configuration that was passed in constructor.
</li>
</ul>
@return \stdClass | [
"Create",
"a",
"new",
"bucket",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L159-L170 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.listObjects | public function listObjects($bucketName, $options = array())
{
list($config, $maxKeys, $prefix, $marker, $delimiter) =
$this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::MAX_KEYS,
BosOptions::PREFIX,
BosOptions::MARKER,
BosOptions::DELIMITER
);
$params = array();
if ($maxKeys !== null) {
if (is_numeric($maxKeys)) {
$maxKeys = number_format($maxKeys);
$maxKeys = str_replace(',','',$maxKeys);
}
$params[BosOptions::MAX_KEYS] = $maxKeys;
}
if ($prefix !== null) {
$params[BosOptions::PREFIX] = $prefix;
}
if ($marker !== null) {
$params[BosOptions::MARKER] = $marker;
}
if ($delimiter !== null) {
$params[BosOptions::DELIMITER] = $delimiter;
}
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => $params
)
);
} | php | public function listObjects($bucketName, $options = array())
{
list($config, $maxKeys, $prefix, $marker, $delimiter) =
$this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::MAX_KEYS,
BosOptions::PREFIX,
BosOptions::MARKER,
BosOptions::DELIMITER
);
$params = array();
if ($maxKeys !== null) {
if (is_numeric($maxKeys)) {
$maxKeys = number_format($maxKeys);
$maxKeys = str_replace(',','',$maxKeys);
}
$params[BosOptions::MAX_KEYS] = $maxKeys;
}
if ($prefix !== null) {
$params[BosOptions::PREFIX] = $prefix;
}
if ($marker !== null) {
$params[BosOptions::MARKER] = $marker;
}
if ($delimiter !== null) {
$params[BosOptions::DELIMITER] = $delimiter;
}
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => $params
)
);
} | [
"public",
"function",
"listObjects",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"maxKeys",
",",
"$",
"prefix",
",",
"$",
"marker",
",",
"$",
"delimiter",
")",
"=",
"$",
"this... | Get Object Information of bucket.
@param string $bucketName The bucket name.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@property number $maxKeys The default value is 1000.
@property string $prefix The default value is null.
@property string $marker The default value is null.
@property string $delimiter The default value is null.
@property mixed $config The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"Object",
"Information",
"of",
"bucket",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L186-L223 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.doesBucketExist | public function doesBucketExist($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
try {
$this->sendRequest(
HttpMethod::HEAD,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName
)
);
return true;
} catch (BceServiceException $e) {
if ($e->getStatusCode() === 403) {
return true;
}
if ($e->getStatusCode() === 404) {
return false;
}
throw $e;
}
} | php | public function doesBucketExist($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
try {
$this->sendRequest(
HttpMethod::HEAD,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName
)
);
return true;
} catch (BceServiceException $e) {
if ($e->getStatusCode() === 403) {
return true;
}
if ($e->getStatusCode() === 404) {
return false;
}
throw $e;
}
} | [
"public",
"function",
"doesBucketExist",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
"::",
"CONFIG",
")"... | Check whether there is some user access to this bucket.
@param string $bucketName The bucket name.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return boolean true means the bucket does exists. | [
"Check",
"whether",
"there",
"is",
"some",
"user",
"access",
"to",
"this",
"bucket",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L233-L255 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.deleteBucket | public function deleteBucket($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::DELETE,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName
)
);
} | php | public function deleteBucket($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::DELETE,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName
)
);
} | [
"public",
"function",
"deleteBucket",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
"::",
"CONFIG",
")",
... | Delete a Bucket
Must delete all the bbjects in this bucket before call this api
@param string $bucketName The bucket name.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Delete",
"a",
"Bucket",
"Must",
"delete",
"all",
"the",
"bbjects",
"in",
"this",
"bucket",
"before",
"call",
"this",
"api"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L266-L277 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.getBucketAcl | public function getBucketAcl($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => array(
BosOptions::ACL => '',
)
)
);
} | php | public function getBucketAcl($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => array(
BosOptions::ACL => '',
)
)
);
} | [
"public",
"function",
"getBucketAcl",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
"::",
"CONFIG",
")",
... | Get Access Control Level of bucket
@param string $bucketName The bucket name.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"Access",
"Control",
"Level",
"of",
"bucket"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L344-L358 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.getBucketLocation | public function getBucketLocation($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
$response = $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => array(
BosOptions::LOCATION => '',
),
)
);
return $response->locationConstraint;
} | php | public function getBucketLocation($bucketName, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
$response = $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => array(
BosOptions::LOCATION => '',
),
)
);
return $response->locationConstraint;
} | [
"public",
"function",
"getBucketLocation",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
"::",
"CONFIG",
"... | Get Region of bucket
@param string $bucketName The bucket name.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"Region",
"of",
"bucket"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L368-L382 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.putObjectFromString | public function putObjectFromString(
$bucketName,
$key,
$data,
$options = array()
) {
return $this->putObject(
$bucketName,
$key,
$data,
strlen($data),
base64_encode(md5($data, true)),
$options
);
} | php | public function putObjectFromString(
$bucketName,
$key,
$data,
$options = array()
) {
return $this->putObject(
$bucketName,
$key,
$data,
strlen($data),
base64_encode(md5($data, true)),
$options
);
} | [
"public",
"function",
"putObjectFromString",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"data",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"putObject",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$"... | Create object and put content of string to the object
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $data The object content.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Create",
"object",
"and",
"put",
"content",
"of",
"string",
"to",
"the",
"object"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L395-L409 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.putObjectFromFile | public function putObjectFromFile(
$bucketName,
$key,
$filename,
$options = array()
) {
if (!isset($options[BosOptions::CONTENT_TYPE])) {
$options[BosOptions::CONTENT_TYPE] = MimeTypes::guessMimeType(
$filename
);
}
list($contentLength, $contentMd5) = $this->parseOptionsIgnoreExtra(
$options,
BosOptions::CONTENT_LENGTH,
BosOptions::CONTENT_MD5
);
if ($contentLength === null) {
$contentLength = filesize($filename);
} else {
if (!is_int($contentLength) && !is_long($contentLength)) {
throw new \InvalidArgumentException(
'$contentLength should be int or long.'
);
}
unset($options[BosOptions::CONTENT_LENGTH]);
}
$fp = fopen($filename, 'rb');
if ($contentMd5 === null) {
$contentMd5 = base64_encode(HashUtils::md5FromStream($fp, 0, $contentLength));
} else {
unset($options[BosOptions::CONTENT_MD5]);
}
try {
$response = $this->putObject(
$bucketName,
$key,
$fp,
$contentLength,
$contentMd5,
$options);
//streams are close in the destructor of stream object in guzzle
if (is_resource($fp)) {
fclose($fp);
}
return $response;
} catch (\Exception $e) {
if (is_resource($fp)) {
fclose($fp);
}
throw $e;
}
} | php | public function putObjectFromFile(
$bucketName,
$key,
$filename,
$options = array()
) {
if (!isset($options[BosOptions::CONTENT_TYPE])) {
$options[BosOptions::CONTENT_TYPE] = MimeTypes::guessMimeType(
$filename
);
}
list($contentLength, $contentMd5) = $this->parseOptionsIgnoreExtra(
$options,
BosOptions::CONTENT_LENGTH,
BosOptions::CONTENT_MD5
);
if ($contentLength === null) {
$contentLength = filesize($filename);
} else {
if (!is_int($contentLength) && !is_long($contentLength)) {
throw new \InvalidArgumentException(
'$contentLength should be int or long.'
);
}
unset($options[BosOptions::CONTENT_LENGTH]);
}
$fp = fopen($filename, 'rb');
if ($contentMd5 === null) {
$contentMd5 = base64_encode(HashUtils::md5FromStream($fp, 0, $contentLength));
} else {
unset($options[BosOptions::CONTENT_MD5]);
}
try {
$response = $this->putObject(
$bucketName,
$key,
$fp,
$contentLength,
$contentMd5,
$options);
//streams are close in the destructor of stream object in guzzle
if (is_resource($fp)) {
fclose($fp);
}
return $response;
} catch (\Exception $e) {
if (is_resource($fp)) {
fclose($fp);
}
throw $e;
}
} | [
"public",
"function",
"putObjectFromFile",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"filename",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"BosOptions",
"::",
"CONTENT_TYPE",
"]",... | Put object and copy content of file to the object
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $filename The absolute file path.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Put",
"object",
"and",
"copy",
"content",
"of",
"file",
"to",
"the",
"object"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L422-L477 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.putObject | public function putObject(
$bucketName,
$key,
$data,
$contentLength,
$contentMd5,
$options = array()
) {
if (empty($key)) {
throw new \InvalidArgumentException('$key should not be empty or null.');
}
if (!is_int($contentLength) && !is_long($contentLength)) {
throw new \InvalidArgumentException(
'$contentLength should be int or long.'
);
}
if ($contentLength < 0) {
throw new \InvalidArgumentException(
'$contentLength should not be negative.'
);
}
if (empty($contentMd5)) {
throw new \InvalidArgumentException(
'$contentMd5 should not be empty or null.'
);
}
$this->checkData($data);
$headers = array();
$headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
$headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
$this->populateRequestHeadersWithOptions($headers, $options);
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'body' => $data,
'headers' => $headers,
)
);
} | php | public function putObject(
$bucketName,
$key,
$data,
$contentLength,
$contentMd5,
$options = array()
) {
if (empty($key)) {
throw new \InvalidArgumentException('$key should not be empty or null.');
}
if (!is_int($contentLength) && !is_long($contentLength)) {
throw new \InvalidArgumentException(
'$contentLength should be int or long.'
);
}
if ($contentLength < 0) {
throw new \InvalidArgumentException(
'$contentLength should not be negative.'
);
}
if (empty($contentMd5)) {
throw new \InvalidArgumentException(
'$contentMd5 should not be empty or null.'
);
}
$this->checkData($data);
$headers = array();
$headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
$headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
$this->populateRequestHeadersWithOptions($headers, $options);
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'body' => $data,
'headers' => $headers,
)
);
} | [
"public",
"function",
"putObject",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"data",
",",
"$",
"contentLength",
",",
"$",
"contentMd5",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
... | Upload a object to one bucket
@param string $bucketName The bucket name.
@param string $key The object path.
@param string|resource $data The object content, which can be a string or a resource.
@param int $contentLength
@param string $contentMd5
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Upload",
"a",
"object",
"to",
"one",
"bucket"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L490-L534 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.getObject | public function getObject(
$bucketName,
$key,
$outputStream,
$options = array()
) {
list($config, $range) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::RANGE
);
$headers = array();
if ($range !== null) {
switch(gettype($range)) {
case 'array':
if (!isset($range[0]) || !(is_int($range[0]) || is_long($range[0]))) {
throw new \InvalidArgumentException(
'range[0] is not defined.'
);
}
if (!isset($range[1]) || !(is_int($range[1]) || is_long($range[1]))) {
throw new \InvalidArgumentException(
'range[1] is not defined.'
);
}
$range = sprintf('%d-%d', $range[0], $range[1]);
break;
case 'string':
break;
default:
throw new \InvalidArgumentException(
'Option "range" should be either an array of two '
. 'integers or a string'
);
}
$headers[HttpHeaders::RANGE] = sprintf('bytes=%s', $range);
}
$response = $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'headers' => $headers,
'outputStream' => $outputStream,
'parseUserMetadata' => true
)
);
return $response;
} | php | public function getObject(
$bucketName,
$key,
$outputStream,
$options = array()
) {
list($config, $range) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::RANGE
);
$headers = array();
if ($range !== null) {
switch(gettype($range)) {
case 'array':
if (!isset($range[0]) || !(is_int($range[0]) || is_long($range[0]))) {
throw new \InvalidArgumentException(
'range[0] is not defined.'
);
}
if (!isset($range[1]) || !(is_int($range[1]) || is_long($range[1]))) {
throw new \InvalidArgumentException(
'range[1] is not defined.'
);
}
$range = sprintf('%d-%d', $range[0], $range[1]);
break;
case 'string':
break;
default:
throw new \InvalidArgumentException(
'Option "range" should be either an array of two '
. 'integers or a string'
);
}
$headers[HttpHeaders::RANGE] = sprintf('bytes=%s', $range);
}
$response = $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'headers' => $headers,
'outputStream' => $outputStream,
'parseUserMetadata' => true
)
);
return $response;
} | [
"public",
"function",
"getObject",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"outputStream",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"range",
")",
"=",
"$",
"this",
"->",
"parseOptions",
... | Get the object from a bucket.
@param string $bucketName The bucket name.
@param string $key The object path.
@param resource $outputStream
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"the",
"object",
"from",
"a",
"bucket",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L546-L596 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.getObjectAsString | public function getObjectAsString(
$bucketName,
$key,
$options = array()
) {
$outputStream = fopen('php://memory', 'r+');
try {
$this->getObject($bucketName, $key, $outputStream, $options);
rewind($outputStream);
$result = stream_get_contents($outputStream);
if (is_resource($outputStream)) {
fclose($outputStream);
}
return $result;
} catch (\Exception $e) {
if (is_resource($outputStream)) {
fclose($outputStream);
}
throw $e;
}
} | php | public function getObjectAsString(
$bucketName,
$key,
$options = array()
) {
$outputStream = fopen('php://memory', 'r+');
try {
$this->getObject($bucketName, $key, $outputStream, $options);
rewind($outputStream);
$result = stream_get_contents($outputStream);
if (is_resource($outputStream)) {
fclose($outputStream);
}
return $result;
} catch (\Exception $e) {
if (is_resource($outputStream)) {
fclose($outputStream);
}
throw $e;
}
} | [
"public",
"function",
"getObjectAsString",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"outputStream",
"=",
"fopen",
"(",
"'php://memory'",
",",
"'r+'",
")",
";",
"try",
"{",
"$",
"this",
"->",
... | Get the object cotent as string
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $range If specified, only get the range part.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"the",
"object",
"cotent",
"as",
"string"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L608-L628 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.getObjectToFile | public function getObjectToFile(
$bucketName,
$key,
$filename,
$options = array()
)
{
$outputStream = fopen($filename, 'w+');
try {
$response = $this->getObject(
$bucketName,
$key,
$outputStream,
$options
);
if(is_resource($outputStream)) {
fclose($outputStream);
}
return $response;
} catch (\Exception $e) {
if(is_resource($outputStream)) {
fclose($outputStream);
}
throw $e;
}
} | php | public function getObjectToFile(
$bucketName,
$key,
$filename,
$options = array()
)
{
$outputStream = fopen($filename, 'w+');
try {
$response = $this->getObject(
$bucketName,
$key,
$outputStream,
$options
);
if(is_resource($outputStream)) {
fclose($outputStream);
}
return $response;
} catch (\Exception $e) {
if(is_resource($outputStream)) {
fclose($outputStream);
}
throw $e;
}
} | [
"public",
"function",
"getObjectToFile",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"filename",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"outputStream",
"=",
"fopen",
"(",
"$",
"filename",
",",
"'w+'",
")",
";",
"try",
"{",... | Get Content of Object and Put Content to File
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $filename The destination file name.
@param string $range The HTTP 'Range' header.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"Content",
"of",
"Object",
"and",
"Put",
"Content",
"to",
"File"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L642-L667 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.getObjectMetadata | public function getObjectMetadata($bucketName, $key, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
$response = $this->sendRequest(
HttpMethod::HEAD,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'parseUserMetadata' => true
)
);
return $response->metadata;
} | php | public function getObjectMetadata($bucketName, $key, $options = array())
{
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
$response = $this->sendRequest(
HttpMethod::HEAD,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'parseUserMetadata' => true
)
);
return $response->metadata;
} | [
"public",
"function",
"getObjectMetadata",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"BosOptions",
... | Get Object meta information
@param string $bucketName The bucket name.
@param string $key The object path.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Get",
"Object",
"meta",
"information"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L706-L721 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.copyObject | public function copyObject(
$sourceBucketName,
$sourceKey,
$targetBucketName,
$targetKey,
$options = array()
) {
if (empty($sourceBucketName)) {
throw new \InvalidArgumentException(
'$sourceBucketName should not be empty or null.'
);
}
if (empty($sourceKey)) {
throw new \InvalidArgumentException(
'$sourceKey should not be empty or null.'
);
}
if (empty($targetBucketName)) {
throw new \InvalidArgumentException(
'$targetBucketName should not be empty or null.'
);
}
if (empty($targetKey)) {
throw new \InvalidArgumentException(
'$targetKey should not be empty or null.'
);
}
list($config, $userMetadata, $etag, $storageClass) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::USER_METADATA,
BosOptions::ETAG,
BosOptions::STORAGE_CLASS
);
$headers = array();
$headers[HttpHeaders::BCE_COPY_SOURCE] =
HttpUtils::urlEncodeExceptSlash(
sprintf("/%s/%s", $sourceBucketName, $sourceKey)
);
if ($etag !== null) {
$etag = trim($etag, '"');
$headers[HttpHeaders::BCE_COPY_SOURCE_IF_MATCH] = '"' . $etag . '"';
}
if ($userMetadata === null) {
$headers[HttpHeaders::BCE_COPY_METADATA_DIRECTIVE] = 'copy';
} else {
$headers[HttpHeaders::BCE_COPY_METADATA_DIRECTIVE] = 'replace';
$this->populateRequestHeadersWithUserMetadata(
$headers,
$userMetadata
);
}
if ($storageClass !== null) {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = $storageClass;
} else {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = StorageClass::STANDARD;
}
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $targetBucketName,
'key' => $targetKey,
'headers' => $headers,
)
);
} | php | public function copyObject(
$sourceBucketName,
$sourceKey,
$targetBucketName,
$targetKey,
$options = array()
) {
if (empty($sourceBucketName)) {
throw new \InvalidArgumentException(
'$sourceBucketName should not be empty or null.'
);
}
if (empty($sourceKey)) {
throw new \InvalidArgumentException(
'$sourceKey should not be empty or null.'
);
}
if (empty($targetBucketName)) {
throw new \InvalidArgumentException(
'$targetBucketName should not be empty or null.'
);
}
if (empty($targetKey)) {
throw new \InvalidArgumentException(
'$targetKey should not be empty or null.'
);
}
list($config, $userMetadata, $etag, $storageClass) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::USER_METADATA,
BosOptions::ETAG,
BosOptions::STORAGE_CLASS
);
$headers = array();
$headers[HttpHeaders::BCE_COPY_SOURCE] =
HttpUtils::urlEncodeExceptSlash(
sprintf("/%s/%s", $sourceBucketName, $sourceKey)
);
if ($etag !== null) {
$etag = trim($etag, '"');
$headers[HttpHeaders::BCE_COPY_SOURCE_IF_MATCH] = '"' . $etag . '"';
}
if ($userMetadata === null) {
$headers[HttpHeaders::BCE_COPY_METADATA_DIRECTIVE] = 'copy';
} else {
$headers[HttpHeaders::BCE_COPY_METADATA_DIRECTIVE] = 'replace';
$this->populateRequestHeadersWithUserMetadata(
$headers,
$userMetadata
);
}
if ($storageClass !== null) {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = $storageClass;
} else {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = StorageClass::STANDARD;
}
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $targetBucketName,
'key' => $targetKey,
'headers' => $headers,
)
);
} | [
"public",
"function",
"copyObject",
"(",
"$",
"sourceBucketName",
",",
"$",
"sourceKey",
",",
"$",
"targetBucketName",
",",
"$",
"targetKey",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sourceBucketName",
")",
")... | Copy one object to another.
@param string $sourceBucketName The source bucket name.
@param string $sourceKey The source object path.
@param string $targetBucketName The target bucket name.
@param string $targetKey The target object path.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Copy",
"one",
"object",
"to",
"another",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L735-L805 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.initiateMultipartUpload | public function initiateMultipartUpload(
$bucketName,
$key,
$options = array()
) {
list($config, $storageClass) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::STORAGE_CLASS);
$headers = array(
HttpHeaders::CONTENT_TYPE => HttpContentTypes::OCTET_STREAM,
);
if ($storageClass !== null) {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = $storageClass;
} else {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = StorageClass::STANDARD;
}
return $this->sendRequest(
HttpMethod::POST,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'headers' => $headers,
'params' => array('uploads' => ''),
)
);
} | php | public function initiateMultipartUpload(
$bucketName,
$key,
$options = array()
) {
list($config, $storageClass) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::STORAGE_CLASS);
$headers = array(
HttpHeaders::CONTENT_TYPE => HttpContentTypes::OCTET_STREAM,
);
if ($storageClass !== null) {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = $storageClass;
} else {
$headers[HttpHeaders::BCE_STORAGE_CLASS] = StorageClass::STANDARD;
}
return $this->sendRequest(
HttpMethod::POST,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'headers' => $headers,
'params' => array('uploads' => ''),
)
);
} | [
"public",
"function",
"initiateMultipartUpload",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"storageClass",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$"... | Initialize multi_upload_file.
@param string $bucketName The bucket name.
@param string $key The object path.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Initialize",
"multi_upload_file",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L817-L846 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.abortMultipartUpload | public function abortMultipartUpload(
$bucketName,
$key,
$uploadId,
$options = array()
) {
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::DELETE,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'params' => array('uploadId' => $uploadId),
)
);
} | php | public function abortMultipartUpload(
$bucketName,
$key,
$uploadId,
$options = array()
) {
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::DELETE,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'params' => array('uploadId' => $uploadId),
)
);
} | [
"public",
"function",
"abortMultipartUpload",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"uploadId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"op... | Abort upload a part which is being uploading.
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $uploadId The uploadId returned by initiateMultipartUpload.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Abort",
"upload",
"a",
"part",
"which",
"is",
"being",
"uploading",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L859-L876 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.uploadPart | public function uploadPart(
$bucketName,
$key,
$uploadId,
$partNumber,
$contentLength,
$contentMd5,
$data,
$options = array()
) {
if (empty($bucketName)) {
throw new \InvalidArgumentException(
'$bucketName should not be empty or null.'
);
}
if (empty($key)) {
throw new \InvalidArgumentException(
'$key should not be empty or null.'
);
}
if (!is_int($contentLength) && !is_long($contentLength)) {
throw new \InvalidArgumentException(
'$contentLength should be int or long.'
);
}
if ($partNumber < BosClient::MIN_PART_NUMBER
|| $partNumber > BosClient::MAX_PART_NUMBER
) {
throw new \InvalidArgumentException(
sprintf(
'Invalid $partNumber %d. The valid range is from %d to %d.',
$partNumber,
BosClient::MIN_PART_NUMBER,
BosClient::MAX_PART_NUMBER
)
);
}
if ($contentMd5 === null) {
throw new \InvalidArgumentException(
'$contentMd5 should not be null.'
);
}
$this->checkData($data);
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
$headers = array();
$headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
$headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
$headers[HttpHeaders::CONTENT_TYPE] = HttpContentTypes::OCTET_STREAM;
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'body' => $data,
'params' => array(
'partNumber' => $partNumber,
'uploadId' => $uploadId
),
'headers' => $headers,
)
);
} | php | public function uploadPart(
$bucketName,
$key,
$uploadId,
$partNumber,
$contentLength,
$contentMd5,
$data,
$options = array()
) {
if (empty($bucketName)) {
throw new \InvalidArgumentException(
'$bucketName should not be empty or null.'
);
}
if (empty($key)) {
throw new \InvalidArgumentException(
'$key should not be empty or null.'
);
}
if (!is_int($contentLength) && !is_long($contentLength)) {
throw new \InvalidArgumentException(
'$contentLength should be int or long.'
);
}
if ($partNumber < BosClient::MIN_PART_NUMBER
|| $partNumber > BosClient::MAX_PART_NUMBER
) {
throw new \InvalidArgumentException(
sprintf(
'Invalid $partNumber %d. The valid range is from %d to %d.',
$partNumber,
BosClient::MIN_PART_NUMBER,
BosClient::MAX_PART_NUMBER
)
);
}
if ($contentMd5 === null) {
throw new \InvalidArgumentException(
'$contentMd5 should not be null.'
);
}
$this->checkData($data);
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
$headers = array();
$headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
$headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
$headers[HttpHeaders::CONTENT_TYPE] = HttpContentTypes::OCTET_STREAM;
return $this->sendRequest(
HttpMethod::PUT,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'body' => $data,
'params' => array(
'partNumber' => $partNumber,
'uploadId' => $uploadId
),
'headers' => $headers,
)
);
} | [
"public",
"function",
"uploadPart",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"uploadId",
",",
"$",
"partNumber",
",",
"$",
"contentLength",
",",
"$",
"contentMd5",
",",
"$",
"data",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if... | Upload a part from a file handle
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $uploadId The uploadId returned by initiateMultipartUpload.
@param int $partNumber The part index, 1-based.
@param int $contentLength The uploaded part size.
@param string $contentMd5 The part md5 check sum.
@param string $data The file pointer.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Upload",
"a",
"part",
"from",
"a",
"file",
"handle"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L893-L960 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.uploadPartFromFile | public function uploadPartFromFile(
$bucketName,
$key,
$uploadId,
$partNumber,
$filename,
$offset = 0,
$length = -1,
$options = array()
) {
if (!is_int($offset) && !is_long($offset)) {
throw new \InvalidArgumentException(
'$offset should be int or long.'
);
}
if (!is_int($length) && !is_long($length)) {
throw new \InvalidArgumentException(
'$length should be int or long.'
);
}
$fp = fopen($filename, 'rb');
try {
if ($length < 0) {
fseek($fp, 0, SEEK_END);
$length = ftell($fp) - $offset;
}
$contentMd5 = base64_encode(HashUtils::md5FromStream($fp, $offset, $length));
fseek($fp, $offset, SEEK_SET);
$response = $this->uploadPart(
$bucketName,
$key,
$uploadId,
$partNumber,
$length,
$contentMd5,
$fp,
$options
);
//guzzle will close fp
if (is_resource($fp)) {
fclose($fp);
}
return $response;
} catch (\Exception $e) {
if(is_resource($fp)) {
fclose($fp);
}
throw $e;
}
} | php | public function uploadPartFromFile(
$bucketName,
$key,
$uploadId,
$partNumber,
$filename,
$offset = 0,
$length = -1,
$options = array()
) {
if (!is_int($offset) && !is_long($offset)) {
throw new \InvalidArgumentException(
'$offset should be int or long.'
);
}
if (!is_int($length) && !is_long($length)) {
throw new \InvalidArgumentException(
'$length should be int or long.'
);
}
$fp = fopen($filename, 'rb');
try {
if ($length < 0) {
fseek($fp, 0, SEEK_END);
$length = ftell($fp) - $offset;
}
$contentMd5 = base64_encode(HashUtils::md5FromStream($fp, $offset, $length));
fseek($fp, $offset, SEEK_SET);
$response = $this->uploadPart(
$bucketName,
$key,
$uploadId,
$partNumber,
$length,
$contentMd5,
$fp,
$options
);
//guzzle will close fp
if (is_resource($fp)) {
fclose($fp);
}
return $response;
} catch (\Exception $e) {
if(is_resource($fp)) {
fclose($fp);
}
throw $e;
}
} | [
"public",
"function",
"uploadPartFromFile",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"uploadId",
",",
"$",
"partNumber",
",",
"$",
"filename",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"-",
"1",
",",
"$",
"options",
"=",
"array... | Upload a part from starting with offset.
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $uploadId The uploadId returned by initiateMultipartUpload.
@param number $partNumber The part index, 1-based.
@param number $length The uploaded part size.
@param string $filename The file name.
@param number $offset The file offset.
@param number $contentMd5 The part md5 check sum.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"Upload",
"a",
"part",
"from",
"starting",
"with",
"offset",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L978-L1028 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.listParts | public function listParts($bucketName, $key, $uploadId, $options = array())
{
if (empty($bucketName)) {
throw new \InvalidArgumentException(
'$bucketName should not be empty or null.'
);
}
if (empty($key)) {
throw new \InvalidArgumentException(
'$key should not be empty or null.'
);
}
if (empty($uploadId)) {
throw new \InvalidArgumentException(
'$uploadId should not be empty or null.'
);
}
list($config, $maxParts, $partNumberMarker) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::LIMIT,
BosOptions::MARKER
);
$params = array();
$params['uploadId'] = $uploadId;
if ($maxParts !== null) {
if (is_numeric($maxParts)) {
$maxParts = number_format($maxParts);
$maxParts = str_replace(',','',$maxParts);
}
$params['maxParts'] = $maxParts;
}
if ($partNumberMarker !== null) {
$params['partNumberMarker'] = $partNumberMarker;
}
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'params' => $params,
)
);
} | php | public function listParts($bucketName, $key, $uploadId, $options = array())
{
if (empty($bucketName)) {
throw new \InvalidArgumentException(
'$bucketName should not be empty or null.'
);
}
if (empty($key)) {
throw new \InvalidArgumentException(
'$key should not be empty or null.'
);
}
if (empty($uploadId)) {
throw new \InvalidArgumentException(
'$uploadId should not be empty or null.'
);
}
list($config, $maxParts, $partNumberMarker) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::LIMIT,
BosOptions::MARKER
);
$params = array();
$params['uploadId'] = $uploadId;
if ($maxParts !== null) {
if (is_numeric($maxParts)) {
$maxParts = number_format($maxParts);
$maxParts = str_replace(',','',$maxParts);
}
$params['maxParts'] = $maxParts;
}
if ($partNumberMarker !== null) {
$params['partNumberMarker'] = $partNumberMarker;
}
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'params' => $params,
)
);
} | [
"public",
"function",
"listParts",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"uploadId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"bucketName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgument... | List parts that have been upload success.
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $uploadId The uploadId returned by initiateMultipartUpload.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"List",
"parts",
"that",
"have",
"been",
"upload",
"success",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L1041-L1087 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.completeMultipartUpload | public function completeMultipartUpload(
$bucketName,
$key,
$uploadId,
array $partList,
$options = array()
) {
if (empty($bucketName)) {
throw new \InvalidArgumentException(
'$bucketName should not be empty or null.'
);
}
if (empty($key)) {
throw new \InvalidArgumentException(
'$key should not be empty or null.'
);
}
if (empty($uploadId)) {
throw new \InvalidArgumentException(
'$uploadId should not be empty or null.'
);
}
$headers = array();
$this->populateRequestHeadersWithOptions($headers, $options);
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::POST,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'body' => json_encode(array('parts' => $partList)),
'headers' => $headers,
'params' => array('uploadId' => $uploadId),
)
);
} | php | public function completeMultipartUpload(
$bucketName,
$key,
$uploadId,
array $partList,
$options = array()
) {
if (empty($bucketName)) {
throw new \InvalidArgumentException(
'$bucketName should not be empty or null.'
);
}
if (empty($key)) {
throw new \InvalidArgumentException(
'$key should not be empty or null.'
);
}
if (empty($uploadId)) {
throw new \InvalidArgumentException(
'$uploadId should not be empty or null.'
);
}
$headers = array();
$this->populateRequestHeadersWithOptions($headers, $options);
list($config) = $this->parseOptions($options, BosOptions::CONFIG);
return $this->sendRequest(
HttpMethod::POST,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'key' => $key,
'body' => json_encode(array('parts' => $partList)),
'headers' => $headers,
'params' => array('uploadId' => $uploadId),
)
);
} | [
"public",
"function",
"completeMultipartUpload",
"(",
"$",
"bucketName",
",",
"$",
"key",
",",
"$",
"uploadId",
",",
"array",
"$",
"partList",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"bucketName",
")",
")",
... | After finish all the task, complete multi_upload_file.
bucket, key, upload_id, part_list, options=None
@param string $bucketName The bucket name.
@param string $key The object path.
@param string $uploadId The upload id.
@param array $partList (partnumber and etag) list
@param array $options
@return mixed | [
"After",
"finish",
"all",
"the",
"task",
"complete",
"multi_upload_file",
".",
"bucket",
"key",
"upload_id",
"part_list",
"options",
"=",
"None"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L1101-L1139 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Bos/BosClient.php | BosClient.listMultipartUploads | public function listMultipartUploads($bucketName, $options = array())
{
list(
$config,
$keyMarker,
$maxUploads,
$delimiter,
$prefix
) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::MARKER,
BosOptions::LIMIT,
BosOptions::DELIMITER,
BosOptions::PREFIX
);
$params = array();
$params['uploads'] = '';
if ($keyMarker !== null) {
$params['keyMarker'] = $keyMarker;
}
if ($maxUploads !== null) {
if (is_numeric($maxUploads)) {
$maxUploads = number_format($maxUploads);
$maxUploads = str_replace(',','',$maxUploads);
}
$params['maxUploads'] = $maxUploads;
}
if ($delimiter !== null) {
$params['delimiter'] = $delimiter;
}
if ($prefix !== null) {
$params['prefix'] = $prefix;
}
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => $params,
)
);
} | php | public function listMultipartUploads($bucketName, $options = array())
{
list(
$config,
$keyMarker,
$maxUploads,
$delimiter,
$prefix
) = $this->parseOptions(
$options,
BosOptions::CONFIG,
BosOptions::MARKER,
BosOptions::LIMIT,
BosOptions::DELIMITER,
BosOptions::PREFIX
);
$params = array();
$params['uploads'] = '';
if ($keyMarker !== null) {
$params['keyMarker'] = $keyMarker;
}
if ($maxUploads !== null) {
if (is_numeric($maxUploads)) {
$maxUploads = number_format($maxUploads);
$maxUploads = str_replace(',','',$maxUploads);
}
$params['maxUploads'] = $maxUploads;
}
if ($delimiter !== null) {
$params['delimiter'] = $delimiter;
}
if ($prefix !== null) {
$params['prefix'] = $prefix;
}
return $this->sendRequest(
HttpMethod::GET,
array(
BosOptions::CONFIG => $config,
'bucket_name' => $bucketName,
'params' => $params,
)
);
} | [
"public",
"function",
"listMultipartUploads",
"(",
"$",
"bucketName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"keyMarker",
",",
"$",
"maxUploads",
",",
"$",
"delimiter",
",",
"$",
"prefix",
")",
"=",... | List Multipart upload task which haven't been ended.
call initiateMultipartUpload but not call completeMultipartUpload or abortMultipartUpload
@param string $bucketName The bucket name.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed | [
"List",
"Multipart",
"upload",
"task",
"which",
"haven",
"t",
"been",
"ended",
".",
"call",
"initiateMultipartUpload",
"but",
"not",
"call",
"completeMultipartUpload",
"or",
"abortMultipartUpload"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Bos/BosClient.php#L1151-L1194 | train |
baidubce/bce-sdk-php | src/BaiduBce/Auth/BceV1Signer.php | BceV1Signer.sign | public function sign(
array $credentials,
$httpMethod,
$path,
$headers,
$params,
$options = array()
) {
if (!isset($options[SignOptions::EXPIRATION_IN_SECONDS])) {
$expirationInSeconds = SignOptions::DEFAULT_EXPIRATION_IN_SECONDS;
} else {
$expirationInSeconds = $options[SignOptions::EXPIRATION_IN_SECONDS];
}
// to compatible with ak/sk or accessKeyId/secretAccessKey
if(isset($credentials['ak'])){
$accessKeyId = $credentials['ak'];
}
if(isset($credentials['sk'])){
$secretAccessKey = $credentials['sk'];
}
if(isset($credentials['accessKeyId'])){
$accessKeyId = $credentials['accessKeyId'];
}
if(isset($credentials['secretAccessKey'])){
$secretAccessKey = $credentials['secretAccessKey'];
}
if (isset($options[SignOptions::TIMESTAMP])) {
$timestamp = $options[SignOptions::TIMESTAMP];
} else {
$timestamp = new \DateTime();
}
$timestamp->setTimezone(DateUtils::$UTC_TIMEZONE);
$authString = BceV1Signer::BCE_AUTH_VERSION . '/' . $accessKeyId . '/'
. DateUtils::formatAlternateIso8601Date(
$timestamp
) . '/' . $expirationInSeconds;
$signingKey = hash_hmac('sha256', $authString, $secretAccessKey);
// Formatting the URL with signing protocol.
$canonicalURI = BceV1Signer::getCanonicalURIPath($path);
// Formatting the query string with signing protocol.
$canonicalQueryString = HttpUtils::getCanonicalQueryString(
$params,
true
);
// Sorted the headers should be signed from the request.
$headersToSign = null;
if (isset($options[SignOptions::HEADERS_TO_SIGN])) {
$headersToSign = $options[SignOptions::HEADERS_TO_SIGN];
}
// Formatting the headers from the request based on signing protocol.
$canonicalHeader = BceV1Signer::getCanonicalHeaders(
BceV1Signer::getHeadersToSign($headers, $headersToSign)
);
$signedHeaders = '';
if ($headersToSign !== null) {
$signedHeaders = strtolower(
trim(implode(";", array_keys($headersToSign)))
);
}
$canonicalRequest = "$httpMethod\n$canonicalURI\n"
. "$canonicalQueryString\n$canonicalHeader";
// Signing the canonical request using key with sha-256 algorithm.
$signature = hash_hmac('sha256', $canonicalRequest, $signingKey);
$authorizationHeader = "$authString/$signedHeaders/$signature";
return $authorizationHeader;
} | php | public function sign(
array $credentials,
$httpMethod,
$path,
$headers,
$params,
$options = array()
) {
if (!isset($options[SignOptions::EXPIRATION_IN_SECONDS])) {
$expirationInSeconds = SignOptions::DEFAULT_EXPIRATION_IN_SECONDS;
} else {
$expirationInSeconds = $options[SignOptions::EXPIRATION_IN_SECONDS];
}
// to compatible with ak/sk or accessKeyId/secretAccessKey
if(isset($credentials['ak'])){
$accessKeyId = $credentials['ak'];
}
if(isset($credentials['sk'])){
$secretAccessKey = $credentials['sk'];
}
if(isset($credentials['accessKeyId'])){
$accessKeyId = $credentials['accessKeyId'];
}
if(isset($credentials['secretAccessKey'])){
$secretAccessKey = $credentials['secretAccessKey'];
}
if (isset($options[SignOptions::TIMESTAMP])) {
$timestamp = $options[SignOptions::TIMESTAMP];
} else {
$timestamp = new \DateTime();
}
$timestamp->setTimezone(DateUtils::$UTC_TIMEZONE);
$authString = BceV1Signer::BCE_AUTH_VERSION . '/' . $accessKeyId . '/'
. DateUtils::formatAlternateIso8601Date(
$timestamp
) . '/' . $expirationInSeconds;
$signingKey = hash_hmac('sha256', $authString, $secretAccessKey);
// Formatting the URL with signing protocol.
$canonicalURI = BceV1Signer::getCanonicalURIPath($path);
// Formatting the query string with signing protocol.
$canonicalQueryString = HttpUtils::getCanonicalQueryString(
$params,
true
);
// Sorted the headers should be signed from the request.
$headersToSign = null;
if (isset($options[SignOptions::HEADERS_TO_SIGN])) {
$headersToSign = $options[SignOptions::HEADERS_TO_SIGN];
}
// Formatting the headers from the request based on signing protocol.
$canonicalHeader = BceV1Signer::getCanonicalHeaders(
BceV1Signer::getHeadersToSign($headers, $headersToSign)
);
$signedHeaders = '';
if ($headersToSign !== null) {
$signedHeaders = strtolower(
trim(implode(";", array_keys($headersToSign)))
);
}
$canonicalRequest = "$httpMethod\n$canonicalURI\n"
. "$canonicalQueryString\n$canonicalHeader";
// Signing the canonical request using key with sha-256 algorithm.
$signature = hash_hmac('sha256', $canonicalRequest, $signingKey);
$authorizationHeader = "$authString/$signedHeaders/$signature";
return $authorizationHeader;
} | [
"public",
"function",
"sign",
"(",
"array",
"$",
"credentials",
",",
"$",
"httpMethod",
",",
"$",
"path",
",",
"$",
"headers",
",",
"$",
"params",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
... | Sign the given request with the given set of credentials. Modifies the passed-in request to apply the signature.
@param $credentials array the credentials to sign the request with.
@param $httpMethod string
@param $path string
@param $headers array
@param $params array
@param $options array the options for signing.
@return string The signed authorization string. | [
"Sign",
"the",
"given",
"request",
"with",
"the",
"given",
"set",
"of",
"credentials",
".",
"Modifies",
"the",
"passed",
"-",
"in",
"request",
"to",
"apply",
"the",
"signature",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Auth/BceV1Signer.php#L56-L129 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Sts/StsClient.php | StsClient.getSessionToken | public function getSessionToken($options = array())
{
list($config, $acl, $durationSeconds) =
$this->parseOptions(
$options,
'config',
'acl',
'durationSeconds'
);
$params = array();
if ($durationSeconds !== null) {
$params['durationSeconds'] = $durationSeconds;
}
$headers = array();
if ($acl !== null) {
$headers[HttpHeaders::CONTENT_LENGTH] = strlen($acl);
} else {
$headers[HttpHeaders::CONTENT_LENGTH] = 0;
}
$headers[HttpHeaders::CONTENT_TYPE] = HttpContentTypes::JSON;
// prevent low version curl add a default pragma:no-cache
$headers[HttpHeaders::PRAGMA] = '';
$config['endpoint'] = $this->stsEndpoint;
$config = array_merge(
$this->config,
$config
);
$path = HttpUtils::appendUri(StsClient::STS_URL_PREFIX, StsClient::GET_SESSION_TOKEN_VERSION, StsClient::GET_SESSION_TOKEN_PATH);
$response = $this->httpClient->sendRequest(
$config,
HttpMethod::POST,
$path,
$acl,
$headers,
$params,
$this->signer
);
return $this->parseJsonResult($response['body']);
} | php | public function getSessionToken($options = array())
{
list($config, $acl, $durationSeconds) =
$this->parseOptions(
$options,
'config',
'acl',
'durationSeconds'
);
$params = array();
if ($durationSeconds !== null) {
$params['durationSeconds'] = $durationSeconds;
}
$headers = array();
if ($acl !== null) {
$headers[HttpHeaders::CONTENT_LENGTH] = strlen($acl);
} else {
$headers[HttpHeaders::CONTENT_LENGTH] = 0;
}
$headers[HttpHeaders::CONTENT_TYPE] = HttpContentTypes::JSON;
// prevent low version curl add a default pragma:no-cache
$headers[HttpHeaders::PRAGMA] = '';
$config['endpoint'] = $this->stsEndpoint;
$config = array_merge(
$this->config,
$config
);
$path = HttpUtils::appendUri(StsClient::STS_URL_PREFIX, StsClient::GET_SESSION_TOKEN_VERSION, StsClient::GET_SESSION_TOKEN_PATH);
$response = $this->httpClient->sendRequest(
$config,
HttpMethod::POST,
$path,
$acl,
$headers,
$params,
$this->signer
);
return $this->parseJsonResult($response['body']);
} | [
"public",
"function",
"getSessionToken",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"acl",
",",
"$",
"durationSeconds",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",... | Get STS session token
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating StsClient instance.
@return object the server response. | [
"Get",
"STS",
"session",
"token"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Sts/StsClient.php#L60-L101 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.createSimpleJob | public function createSimpleJob(
$pipelineName,
$sourceKey,
$targetKey,
$presetName,
$options = array()
) {
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (empty($sourceKey)) {
throw new BceClientException("The parameter sourceKey "
."should NOT be null or empty string");
}
if (empty($targetKey)) {
throw new BceClientException("The parameter targetKey "
."should NOT be null or empty string");
}
if (empty($presetName)) {
throw new BceClientException("The parameter presetName "
."should NOT be null or empty string");
}
return $this->createJob(
$pipelineName,
array(
'sourceKey' => $sourceKey,
),
array(
'targetKey' => $targetKey,
'presetName' => $presetName,
),
$options
);
} | php | public function createSimpleJob(
$pipelineName,
$sourceKey,
$targetKey,
$presetName,
$options = array()
) {
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (empty($sourceKey)) {
throw new BceClientException("The parameter sourceKey "
."should NOT be null or empty string");
}
if (empty($targetKey)) {
throw new BceClientException("The parameter targetKey "
."should NOT be null or empty string");
}
if (empty($presetName)) {
throw new BceClientException("The parameter presetName "
."should NOT be null or empty string");
}
return $this->createJob(
$pipelineName,
array(
'sourceKey' => $sourceKey,
),
array(
'targetKey' => $targetKey,
'presetName' => $presetName,
),
$options
);
} | [
"public",
"function",
"createSimpleJob",
"(",
"$",
"pipelineName",
",",
"$",
"sourceKey",
",",
"$",
"targetKey",
",",
"$",
"presetName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pipelineName",
")",
")",
"{",... | Create a job, a simpler api
@param string $pipelineName The pipeline name
@param string $sourceKey The source media object's key
@param string $targetKey The target media object's key
which will be generated
@param string $presetName The preset name this job use
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"job",
"a",
"simpler",
"api"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L107-L146 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.getJob | public function getJob($jobId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($jobId)) {
throw new BceClientException("The parameter jobId "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/job/$jobId"
);
} | php | public function getJob($jobId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($jobId)) {
throw new BceClientException("The parameter jobId "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/job/$jobId"
);
} | [
"public",
"function",
"getJob",
"(",
"$",
"jobId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"empty",
... | Get the specific job information
@param string $jobId The job's id
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"the",
"specific",
"job",
"information"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L217-L233 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.getMediaInfoOfFile | public function getMediaInfoOfFile($bucket, $key, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($bucket)) {
throw new BceClientException("The parameter bucket "
."should NOT be null or empty string");
}
if (empty($key)) {
throw new BceClientException("The parameter key "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => array(
'bucket' => $bucket,
'key' => rawurlencode($key),
),
),
'/mediainfo'
);
} | php | public function getMediaInfoOfFile($bucket, $key, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($bucket)) {
throw new BceClientException("The parameter bucket "
."should NOT be null or empty string");
}
if (empty($key)) {
throw new BceClientException("The parameter key "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => array(
'bucket' => $bucket,
'key' => rawurlencode($key),
),
),
'/mediainfo'
);
} | [
"public",
"function",
"getMediaInfoOfFile",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")"... | Get the information of a media object in BOS
@param string $bucket The bucket's name in BOS
@param string $key The object's key in bucket
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"the",
"information",
"of",
"a",
"media",
"object",
"in",
"BOS"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L248-L273 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.createPipeline | public function createPipeline(
$pipelineName,
$sourceBucket,
$targetBucket,
$options = array()
) {
list($config, $description, $pipelineConfig) = $this->parseOptions(
$options,
'config',
'description',
'pipelineConfig'
);
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (empty($sourceBucket)) {
throw new BceClientException("The parameter sourceBucket "
."should NOT be null or empty string");
}
if (empty($targetBucket)) {
throw new BceClientException("The parameter targetBucket "
."should NOT be null or empty string");
}
$body = array(
'pipelineName' => $pipelineName,
'sourceBucket' => $sourceBucket,
'targetBucket' => $targetBucket,
);
if ($description !== null) {
$body['description'] = $description;
} else {
$body['description'] = '';
}
if ($pipelineConfig !== null) {
$body['config'] = $pipelineConfig;
} else {
$body['config'] = array('capacity' => 20);
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/pipeline'
);
} | php | public function createPipeline(
$pipelineName,
$sourceBucket,
$targetBucket,
$options = array()
) {
list($config, $description, $pipelineConfig) = $this->parseOptions(
$options,
'config',
'description',
'pipelineConfig'
);
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (empty($sourceBucket)) {
throw new BceClientException("The parameter sourceBucket "
."should NOT be null or empty string");
}
if (empty($targetBucket)) {
throw new BceClientException("The parameter targetBucket "
."should NOT be null or empty string");
}
$body = array(
'pipelineName' => $pipelineName,
'sourceBucket' => $sourceBucket,
'targetBucket' => $targetBucket,
);
if ($description !== null) {
$body['description'] = $description;
} else {
$body['description'] = '';
}
if ($pipelineConfig !== null) {
$body['config'] = $pipelineConfig;
} else {
$body['config'] = array('capacity' => 20);
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/pipeline'
);
} | [
"public",
"function",
"createPipeline",
"(",
"$",
"pipelineName",
",",
"$",
"sourceBucket",
",",
"$",
"targetBucket",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"description",
",",
"$",
"pipelineConfig",
... | Create a pipeline
@param string $pipelineName The pipeline name
@param string $sourceBucket The input source bucket's name in BOS
@param string $targetBucket The output target bucket's name in BOS
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
pipelineConfig: {
capacity: The capacity of pipeline
}
description: The description of pipeline
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"pipeline"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L316-L368 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.getPipeline | public function getPipeline($pipelineName, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/pipeline/$pipelineName"
);
} | php | public function getPipeline($pipelineName, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/pipeline/$pipelineName"
);
} | [
"public",
"function",
"getPipeline",
"(",
"$",
"pipelineName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
... | Get the specific pipeline information
@param string $pipelineName The pipeline name
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"the",
"specific",
"pipeline",
"information"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L382-L398 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.deletePipeline | public function deletePipeline($pipelineName, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/pipeline/$pipelineName"
);
} | php | public function deletePipeline($pipelineName, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/pipeline/$pipelineName"
);
} | [
"public",
"function",
"deletePipeline",
"(",
"$",
"pipelineName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(... | Delete the specific pipeline
@param string $pipelineName The pipeline name
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Delete",
"the",
"specific",
"pipeline"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L412-L428 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.createPreset | public function createPreset($presetName, $container, $options = array())
{
list($config) = $this->parseOptionsIgnoreExtra(
$options,
'config'
);
if (empty($presetName)) {
throw new BceClientException("The parameter presetName "
."should NOT be null or empty string");
}
if (empty($container)) {
throw new BceClientException("The parameter container "
."should NOT be null or empty string");
}
if (!empty($config)) {
unset($options['config']);
}
$body = $options;
$body['presetName'] = $presetName;
$body['container'] = $container;
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/preset'
);
} | php | public function createPreset($presetName, $container, $options = array())
{
list($config) = $this->parseOptionsIgnoreExtra(
$options,
'config'
);
if (empty($presetName)) {
throw new BceClientException("The parameter presetName "
."should NOT be null or empty string");
}
if (empty($container)) {
throw new BceClientException("The parameter container "
."should NOT be null or empty string");
}
if (!empty($config)) {
unset($options['config']);
}
$body = $options;
$body['presetName'] = $presetName;
$body['container'] = $container;
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/preset'
);
} | [
"public",
"function",
"createPreset",
"(",
"$",
"presetName",
",",
"$",
"container",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptionsIgnoreExtra",
"(",
"$",
"options",
",",
"'... | Create a preset
@param string $presetName The preset's name
@param string $container enum(MP4, FLV, HLS, MP3, M4A)
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
description: The preset's description
transmux(boolean): whether only preceed format transformation
clip: { cut the video or audio
startTimeInSecond: The start time from video
durationInSecond: The duration time from video in seconds
}
audio: { audio preceeding set, default to be video preceeding only
bitRateInBps: The target audio bit rate
sampleRateInHz:
channels: The number of audio's channels
}
video: { video proceeding set, default to be audio preceeding only
codec: H.264
codecOptions: {
profile: enum(baseline, main, high)
}
bitRateInBps: The target video bit rate
maxFrameRate: The max frame rate, enum(10,15, 23.97, 24, 25, 29.97, 30, 50, 60)
maxWidthInPixel: The target video's max width in pixel, range(128, 4096)
maxHeightInPixel: The target video's max height in pixel, range(96, 3072)
sizingPolicy: enum(Keep, ShrinkToFit, Stretch)
}
encryption: {
strategy: enum(Fixed)
aesKey: The aes 128-bit secret key
}
watermarkId: watermarkId
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"preset"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L471-L503 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.createThumbnailJob | public function createThumbnailJob($pipelineName, array $source, $options = array()) {
list($config, $target, $capture) = $this->parseOptions(
$options,
'config',
'target',
'capture'
);
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (empty($source)) {
throw new BceClientException("The parameter source "
."should NOT be null or empty string");
}
$body = array(
'pipelineName' => $pipelineName,
'source' => $source,
);
if ($target !== null) {
$body['target'] = $target;
}
if ($capture !== null) {
$body['capture'] = $capture;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/job/thumbnail'
);
} | php | public function createThumbnailJob($pipelineName, array $source, $options = array()) {
list($config, $target, $capture) = $this->parseOptions(
$options,
'config',
'target',
'capture'
);
if (empty($pipelineName)) {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (empty($source)) {
throw new BceClientException("The parameter source "
."should NOT be null or empty string");
}
$body = array(
'pipelineName' => $pipelineName,
'source' => $source,
);
if ($target !== null) {
$body['target'] = $target;
}
if ($capture !== null) {
$body['capture'] = $capture;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/job/thumbnail'
);
} | [
"public",
"function",
"createThumbnailJob",
"(",
"$",
"pipelineName",
",",
"array",
"$",
"source",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"target",
",",
"$",
"capture",
")",
"=",
"$",
"this",
"->"... | Create a job of generating thumbnail
@param string $pipelineName the pipeline name
@param array $source
{
key: The source media object's key
}
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
target: { The target thumbnail info set
keyPrefix: Prefix of the target thumbnail
format: Target thumbnail file format, enum(jpg, png), only jpg is supported now
sizingPolicy: enum(keep, shrinkToFit, stretch)
widthInPixel: The target thumbnail width in pixel
heightInPixel: The target thumbnail height in pixel
}
capture: { The rules to generate the thumbnail
mode: enum(auto, manual)
startTimeInSecond: The start time
endTimeInSecond: The end time
intervalInSecond: The time interval
}
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"job",
"of",
"generating",
"thumbnail"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L618-L656 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.listThumbnailJobsByPipelineName | public function listThumbnailJobsByPipelineName(
$pipelineName,
$jobStatus = null,
$begin = null,
$end = null,
$options = array()
) {
list($config) = $this->parseOptions($options, 'config');
$params = array();
if (!empty($pipelineName)) {
$params['pipelineName'] = $pipelineName;
} else {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (!empty($jobStatus)) {
$params['jobStatus'] = $jobStatus;
}
if (!empty($begin)) {
$params['begin'] = $begin;
}
if (!empty($end)) {
$params['end'] = $end;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/job/thumbnail"
);
} | php | public function listThumbnailJobsByPipelineName(
$pipelineName,
$jobStatus = null,
$begin = null,
$end = null,
$options = array()
) {
list($config) = $this->parseOptions($options, 'config');
$params = array();
if (!empty($pipelineName)) {
$params['pipelineName'] = $pipelineName;
} else {
throw new BceClientException("The parameter pipelineName "
."should NOT be null or empty string");
}
if (!empty($jobStatus)) {
$params['jobStatus'] = $jobStatus;
}
if (!empty($begin)) {
$params['begin'] = $begin;
}
if (!empty($end)) {
$params['end'] = $end;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/job/thumbnail"
);
} | [
"public",
"function",
"listThumbnailJobsByPipelineName",
"(",
"$",
"pipelineName",
",",
"$",
"jobStatus",
"=",
"null",
",",
"$",
"begin",
"=",
"null",
",",
"$",
"end",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$"... | Get thumbnail jobs
@param string $pipelineName The pipeline name
@param string $jobStatus The jobStatus of the thumbnail job, not filter if null
@param string $begin The createTime should be later than or equals with begin, not check if null
@param string $end The createTime should be earlier than or equals with end, not check if null
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"thumbnail",
"jobs"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L703-L736 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.createWatermark | public function createWatermark(
$bucket,
$key,
$options = array()
) {
list(
$config,
$verticalAlignment,
$horizontalAlignment,
$verticalOffsetInPixel,
$horizontalOffsetInPixel
) = $this->parseOptions(
$options,
'config',
'verticalAlignment',
'horizontalAlignment',
'verticalOffsetInPixel',
'horizontalOffsetInPixel'
);
if (empty($bucket)) {
throw new BceClientException("The parameter bucket "
."should NOT be null or empty string");
}
if (empty($key)) {
throw new BceClientException("The parameter key "
."should NOT be null or empty string");
}
$body = array(
'bucket' => $bucket,
'key' => $key,
);
if ($verticalAlignment !== null) {
$body['verticalAlignment'] = $verticalAlignment;
}
if ($horizontalAlignment !== null) {
$body['horizontalAlignment'] = $horizontalAlignment;
}
if ($verticalOffsetInPixel !== null) {
$body['verticalOffsetInPixel'] = $verticalOffsetInPixel;
}
if ($horizontalOffsetInPixel !== null) {
$body['horizontalOffsetInPixel'] = $horizontalOffsetInPixel;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/watermark'
);
} | php | public function createWatermark(
$bucket,
$key,
$options = array()
) {
list(
$config,
$verticalAlignment,
$horizontalAlignment,
$verticalOffsetInPixel,
$horizontalOffsetInPixel
) = $this->parseOptions(
$options,
'config',
'verticalAlignment',
'horizontalAlignment',
'verticalOffsetInPixel',
'horizontalOffsetInPixel'
);
if (empty($bucket)) {
throw new BceClientException("The parameter bucket "
."should NOT be null or empty string");
}
if (empty($key)) {
throw new BceClientException("The parameter key "
."should NOT be null or empty string");
}
$body = array(
'bucket' => $bucket,
'key' => $key,
);
if ($verticalAlignment !== null) {
$body['verticalAlignment'] = $verticalAlignment;
}
if ($horizontalAlignment !== null) {
$body['horizontalAlignment'] = $horizontalAlignment;
}
if ($verticalOffsetInPixel !== null) {
$body['verticalOffsetInPixel'] = $verticalOffsetInPixel;
}
if ($horizontalOffsetInPixel !== null) {
$body['horizontalOffsetInPixel'] = $horizontalOffsetInPixel;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/watermark'
);
} | [
"public",
"function",
"createWatermark",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"verticalAlignment",
",",
"$",
"horizontalAlignment",
",",
"$",
"verticalOffsetInPixe... | Create a watermark
@param string $bucket The source media BOS bucket
@param string $key the source media object key
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
verticalAlignment: watermark vertical alignment, enum(top, center, bottom)
horizontalAlignment: watermark vertical alignment, enum(left, center, right)
verticalOffsetInPixel: numeric vertical offset, 0~3072
horizontalOffsetInPixel: numeric vertical offset, 0~4096
}
@return mixed
@throws BceClientException
@since 0.8.4 | [
"Create",
"a",
"watermark"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L756-L811 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.getWatermark | public function getWatermark($watermarkId, $options = array()) {
list($config) = $this->parseOptions($options, 'config');
if (empty($watermarkId)) {
throw new BceClientException("The parameter watermarkId "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/watermark/$watermarkId"
);
} | php | public function getWatermark($watermarkId, $options = array()) {
list($config) = $this->parseOptions($options, 'config');
if (empty($watermarkId)) {
throw new BceClientException("The parameter watermarkId "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/watermark/$watermarkId"
);
} | [
"public",
"function",
"getWatermark",
"(",
"$",
"watermarkId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
... | Get a watermark
@param string $watermarkId The watermark id
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"a",
"watermark"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L825-L840 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Media/MediaClient.php | MediaClient.deleteWatermark | public function deleteWatermark($watermarkId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($watermarkId)) {
throw new BceClientException("The parameter watermarkId "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/watermark/$watermarkId"
);
} | php | public function deleteWatermark($watermarkId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($watermarkId)) {
throw new BceClientException("The parameter watermarkId "
."should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/watermark/$watermarkId"
);
} | [
"public",
"function",
"deleteWatermark",
"(",
"$",
"watermarkId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(... | Delete the specific watermark
@param string $watermarkId The watermark Id
@param array $options Supported options:
{
config: The optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Delete",
"the",
"specific",
"watermark"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Media/MediaClient.php#L878-L892 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.applyMedia | public function applyMedia($options = array())
{
list($config) = $this->parseOptions($options, 'config');
$params = array(
'apply' => null,
);
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'params' => $params,
),
'/media'
);
} | php | public function applyMedia($options = array())
{
list($config) = $this->parseOptions($options, 'config');
$params = array(
'apply' => null,
);
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'params' => $params,
),
'/media'
);
} | [
"public",
"function",
"applyMedia",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'... | apply a vod media
Apply a new vod media, get mediaId, sourceBucket, sourceKey.
You account have the access to write the sourceBucket and sourceKey.
You need upload video to sourceBucket and sourceKey via BosClient,
Then call processMedia method to get a VOD media.
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed created vod media info
@throws BceClientException | [
"apply",
"a",
"vod",
"media",
"Apply",
"a",
"new",
"vod",
"media",
"get",
"mediaId",
"sourceBucket",
"sourceKey",
".",
"You",
"account",
"have",
"the",
"access",
"to",
"write",
"the",
"sourceBucket",
"and",
"sourceKey",
".",
"You",
"need",
"upload",
"video",... | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L71-L86 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.processMedia | public function processMedia($mediaId, $title, $description, $options = array())
{
list($config, $extension, $presetGroup) =
$this->parseOptions($options, 'config', 'sourceExtension', 'transcodingPresetGroupName');
$params = array(
'process' => null,
);
$body = array(
'title' => $title,
'description' => $description,
'sourceExtension' => $extension,
'transcodingPresetGroupName' => $presetGroup,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
'body' => json_encode($body),
),
"/media/$mediaId"
);
} | php | public function processMedia($mediaId, $title, $description, $options = array())
{
list($config, $extension, $presetGroup) =
$this->parseOptions($options, 'config', 'sourceExtension', 'transcodingPresetGroupName');
$params = array(
'process' => null,
);
$body = array(
'title' => $title,
'description' => $description,
'sourceExtension' => $extension,
'transcodingPresetGroupName' => $presetGroup,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
'body' => json_encode($body),
),
"/media/$mediaId"
);
} | [
"public",
"function",
"processMedia",
"(",
"$",
"mediaId",
",",
"$",
"title",
",",
"$",
"description",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"extension",
",",
"$",
"presetGroup",
")",
"=",
"$",
... | process a vod media
After applying media, uploading original video to bosClient,
you MUST call processMedia method to get a VOD media.
@param $mediaId
@param $title string, the title of the media
@param $description string, the description of the media
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
sourceExtension: extension of the media source.
transcodingPresetGroupName: preset group to be used for the media
}
@return mixed created vod media info
@throws BceClientException | [
"process",
"a",
"vod",
"media",
"After",
"applying",
"media",
"uploading",
"original",
"video",
"to",
"bosClient",
"you",
"MUST",
"call",
"processMedia",
"method",
"to",
"get",
"a",
"VOD",
"media",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L106-L129 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.rerunMedia | public function rerunMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
$params = array(
'rerun' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/media/$mediaId"
);
} | php | public function rerunMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
$params = array(
'rerun' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/media/$mediaId"
);
} | [
"public",
"function",
"rerunMedia",
"(",
"$",
"mediaId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"$",
"params",
... | rerun a vod media
you can call rerunMedia method to re-process a VOD media.
@param $mediaId
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed created vod media info
@throws BceClientException | [
"rerun",
"a",
"vod",
"media",
"you",
"can",
"call",
"rerunMedia",
"method",
"to",
"re",
"-",
"process",
"a",
"VOD",
"media",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L145-L161 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.createMediaFromFile | public function createMediaFromFile($fileName, $title, $description = '', $options = array())
{
if (empty($fileName)) {
throw new BceClientException("The parameter fileName should NOT be null or empty string");
}
if (empty($title)) {
throw new BceClientException("The parameter title should NOT be null or empty string");
}
// apply media
$uploadInfo = $this->applyMedia($options);
// upload file to bos
$this->uploadMedia($fileName, $uploadInfo->sourceBucket, $uploadInfo->sourceKey);
// process media
// try to cal the extension of the file
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (!preg_match("/^[a-z0-9]{0,10}$/", $extension)) {
$extension = '';
}
$options['extension'] = $extension;
return $this->processMedia($uploadInfo->mediaId, $title, $description, $options);
} | php | public function createMediaFromFile($fileName, $title, $description = '', $options = array())
{
if (empty($fileName)) {
throw new BceClientException("The parameter fileName should NOT be null or empty string");
}
if (empty($title)) {
throw new BceClientException("The parameter title should NOT be null or empty string");
}
// apply media
$uploadInfo = $this->applyMedia($options);
// upload file to bos
$this->uploadMedia($fileName, $uploadInfo->sourceBucket, $uploadInfo->sourceKey);
// process media
// try to cal the extension of the file
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (!preg_match("/^[a-z0-9]{0,10}$/", $extension)) {
$extension = '';
}
$options['extension'] = $extension;
return $this->processMedia($uploadInfo->mediaId, $title, $description, $options);
} | [
"public",
"function",
"createMediaFromFile",
"(",
"$",
"fileName",
",",
"$",
"title",
",",
"$",
"description",
"=",
"''",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fileName",
")",
")",
"{",
"throw",
"new",
... | Create a vod media via local file.
@param $fileName string, path of local file
@param $title string, the title of the media
@param $description string, the description of the media, optional
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed created vod media info
@throws BceClientException | [
"Create",
"a",
"vod",
"media",
"via",
"local",
"file",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L218-L239 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.createMediaFromBosObject | public function createMediaFromBosObject($bucket, $key, $title, $description = '', $options = array())
{
if (empty($bucket)) {
throw new BceClientException("The parameter fileName should NOT be null or empty string");
}
if (empty($key)) {
throw new BceClientException("The parameter fileName should NOT be null or empty string");
}
if (empty($title)) {
throw new BceClientException("The parameter title should NOT be null or empty string");
}
// apply media
$uploadInfo = $this->applyMedia($options);
// copy bos object
$this->bosClient->copyObject($bucket, $key, $uploadInfo->sourceBucket, $uploadInfo->sourceKey);
// process media
// try to cal the extension of the file
$extension = strtolower(pathinfo($key, PATHINFO_EXTENSION));
if (!preg_match("/^[a-z0-9]{0,10}$/", $extension)) {
$extension = '';
}
$options['extension'] = $extension;
return $this->processMedia($uploadInfo->mediaId, $title, $description, $options);
} | php | public function createMediaFromBosObject($bucket, $key, $title, $description = '', $options = array())
{
if (empty($bucket)) {
throw new BceClientException("The parameter fileName should NOT be null or empty string");
}
if (empty($key)) {
throw new BceClientException("The parameter fileName should NOT be null or empty string");
}
if (empty($title)) {
throw new BceClientException("The parameter title should NOT be null or empty string");
}
// apply media
$uploadInfo = $this->applyMedia($options);
// copy bos object
$this->bosClient->copyObject($bucket, $key, $uploadInfo->sourceBucket, $uploadInfo->sourceKey);
// process media
// try to cal the extension of the file
$extension = strtolower(pathinfo($key, PATHINFO_EXTENSION));
if (!preg_match("/^[a-z0-9]{0,10}$/", $extension)) {
$extension = '';
}
$options['extension'] = $extension;
return $this->processMedia($uploadInfo->mediaId, $title, $description, $options);
} | [
"public",
"function",
"createMediaFromBosObject",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"$",
"title",
",",
"$",
"description",
"=",
"''",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"bucket",
")",
")",
"... | Create a vod media via bos object.
@param $bucket string, bos bucket name
@param $key string, bos object key
@param $title string, the title of the media
@param $description string, the description of the media, optional
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed created vod media info
@throws BceClientException | [
"Create",
"a",
"vod",
"media",
"via",
"bos",
"object",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L257-L280 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.getMedia | public function getMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/media/$mediaId"
);
} | php | public function getMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/media/$mediaId"
);
} | [
"public",
"function",
"getMedia",
"(",
"$",
"mediaId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"empty... | get the info of a vod media by mediaId
@param $mediaId string, mediaId of the media
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed media info
@throws BceClientException | [
"get",
"the",
"info",
"of",
"a",
"vod",
"media",
"by",
"mediaId"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L294-L309 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.listMediaByMarker | public function listMediaByMarker($options = array())
{
list($config, $marker, $maxSize, $title, $status, $begin, $end) =
$this->parseOptions($options, 'config', 'marker', 'maxSize', 'title', 'status', 'begin', 'end');
$params = array(
'marker' => $marker,
'maxSize' => $maxSize,
'title' => $title,
'status' => $status,
'begin' => $begin,
'end' => $end,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/media'
);
} | php | public function listMediaByMarker($options = array())
{
list($config, $marker, $maxSize, $title, $status, $begin, $end) =
$this->parseOptions($options, 'config', 'marker', 'maxSize', 'title', 'status', 'begin', 'end');
$params = array(
'marker' => $marker,
'maxSize' => $maxSize,
'title' => $title,
'status' => $status,
'begin' => $begin,
'end' => $end,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/media'
);
} | [
"public",
"function",
"listMediaByMarker",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"marker",
",",
"$",
"maxSize",
",",
"$",
"title",
",",
"$",
"status",
",",
"$",
"begin",
",",
"$",
"end",
")",
... | get the info of current user's all vod media by marker
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
marker: string, marker of current query
maxSize: int, max size of media(s) of current query
title: string, title prefix of the media(s)
status: string, status of the media(s)
begin: string, the low limit of the createTime of the media(s)
end: string, the upper limit of the createTime of the media(s)
}
@return mixed the info of user's all media
@throws BceClientException | [
"get",
"the",
"info",
"of",
"current",
"user",
"s",
"all",
"vod",
"media",
"by",
"marker"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L328-L350 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.listMediaByPage | public function listMediaByPage($pageNo,
$pageSize,
$options = array())
{
list($config, $title, $status, $begin, $end) =
$this->parseOptions($options, 'config', 'title', 'status', 'begin', 'end');
$params = array(
'pageNo' => $pageNo,
'pageSize' => $pageSize,
'title' => $title,
'status' => $status,
'begin' => $begin,
'end' => $end,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/media'
);
} | php | public function listMediaByPage($pageNo,
$pageSize,
$options = array())
{
list($config, $title, $status, $begin, $end) =
$this->parseOptions($options, 'config', 'title', 'status', 'begin', 'end');
$params = array(
'pageNo' => $pageNo,
'pageSize' => $pageSize,
'title' => $title,
'status' => $status,
'begin' => $begin,
'end' => $end,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/media'
);
} | [
"public",
"function",
"listMediaByPage",
"(",
"$",
"pageNo",
",",
"$",
"pageSize",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"title",
",",
"$",
"status",
",",
"$",
"begin",
",",
"$",
"end",
")",
... | get the info of current user's all vod media by page
@param $pageNo integer, pageNo of the resultSet
@param $pageSize integer, pageSize of the resultSet
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
title: string, title prefix of the media(s)
status: string, status of the media(s)
begin: string, the low limit of the createTime of the media(s)
end: string, the upper limit of the createTime of the media(s)
}
@return mixed the info of user's all media
@throws BceClientException | [
"get",
"the",
"info",
"of",
"current",
"user",
"s",
"all",
"vod",
"media",
"by",
"page"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L369-L393 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.updateMedia | public function updateMedia($mediaId, $title, $description, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
if (empty($title)) {
throw new BceClientException("The parameter title should NOT be null or empty string");
}
$body = array(
'title' => $title,
'description' => $description,
);
$params = array(
'attributes' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'body' => json_encode($body),
'params' => $params,
),
"/media/$mediaId"
);
} | php | public function updateMedia($mediaId, $title, $description, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
if (empty($title)) {
throw new BceClientException("The parameter title should NOT be null or empty string");
}
$body = array(
'title' => $title,
'description' => $description,
);
$params = array(
'attributes' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'body' => json_encode($body),
'params' => $params,
),
"/media/$mediaId"
);
} | [
"public",
"function",
"updateMedia",
"(",
"$",
"mediaId",
",",
"$",
"title",
",",
"$",
"description",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",... | update the attributes of a vod media
@param $mediaId string, mediaId of the media
@param $title string, new title of the media
@param $description string, new description of the media
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed the result of updating
@throws BceClientException | [
"update",
"the",
"attributes",
"of",
"a",
"vod",
"media"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L409-L439 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.publishMedia | public function publishMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
$params = array(
'publish' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/media/$mediaId"
);
} | php | public function publishMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
$params = array(
'publish' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/media/$mediaId"
);
} | [
"public",
"function",
"publishMedia",
"(",
"$",
"mediaId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"e... | publish a vod media
@param $mediaId string, mediaId of the media
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed the result of publishing
@throws BceClientException | [
"publish",
"a",
"vod",
"media"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L534-L554 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.getMediaStatistic | public function getMediaStatistic($mediaId,
$startTime,
$endTime,
$aggregate,
$options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
$params = array();
if (!empty($startTime)) {
$params['startTime'] = $startTime;
}
if (!empty($endTime)) {
$params['endTime'] = $endTime;
}
if (!empty($aggregate)) {
$params['aggregate'] = $aggregate;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistic/media/$mediaId"
);
} | php | public function getMediaStatistic($mediaId,
$startTime,
$endTime,
$aggregate,
$options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
$params = array();
if (!empty($startTime)) {
$params['startTime'] = $startTime;
}
if (!empty($endTime)) {
$params['endTime'] = $endTime;
}
if (!empty($aggregate)) {
$params['aggregate'] = $aggregate;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistic/media/$mediaId"
);
} | [
"public",
"function",
"getMediaStatistic",
"(",
"$",
"mediaId",
",",
"$",
"startTime",
",",
"$",
"endTime",
",",
"$",
"aggregate",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseO... | get the statistic of a vod media
@param $mediaId string, mediaId of the media
@param $startTime string
@param $endTime string
@param $aggregate string, 'true' or 'false'
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed the result of publishing
@throws BceClientException | [
"get",
"the",
"statistic",
"of",
"a",
"vod",
"media"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L572-L601 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.deleteMedia | public function deleteMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/media/$mediaId"
);
} | php | public function deleteMedia($mediaId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/media/$mediaId"
);
} | [
"public",
"function",
"deleteMedia",
"(",
"$",
"mediaId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"em... | delete a vod media
@param $mediaId string, mediaId of the media
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed the result of deleting
@throws BceClientException | [
"delete",
"a",
"vod",
"media"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L615-L630 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.getMediaSource | public function getMediaSource($mediaId, $expiredInSeconds, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
if (empty($expiredInSeconds)) {
$expiredInSeconds = -1;
}
$params = array(
'sourcedownload' => null,
'expiredInSeconds' => $expiredInSeconds,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/media/$mediaId"
);
} | php | public function getMediaSource($mediaId, $expiredInSeconds, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($mediaId)) {
throw new BceClientException("The parameter mediaId should NOT be null or empty string");
}
if (empty($expiredInSeconds)) {
$expiredInSeconds = -1;
}
$params = array(
'sourcedownload' => null,
'expiredInSeconds' => $expiredInSeconds,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/media/$mediaId"
);
} | [
"public",
"function",
"getMediaSource",
"(",
"$",
"mediaId",
",",
"$",
"expiredInSeconds",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'confi... | get the source download info of a vod media
@param $mediaId string, mediaId of the media
@param $expiredInSeconds integer, expire time of the url
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default vod client configuration that was passed in constructor.
}
@return mixed the vod media's playable source file and cover page
@throws BceClientException | [
"get",
"the",
"source",
"download",
"info",
"of",
"a",
"vod",
"media"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L958-L981 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Vod/VodClient.php | VodClient.uploadMedia | private function uploadMedia($fileName, $bucket, $key)
{
// init multi-part upload
$initUploadResponse = $this->bosClient->initiateMultipartUpload($bucket, $key);
$uploadId = $initUploadResponse->uploadId;
// do upload part
try {
$offset = 0;
$partNumber = 1;
$partSize = BosClient::MIN_PART_SIZE;
$length = $partSize;
$partList = array();
$bytesLeft = filesize($fileName);
while ($bytesLeft > 0) {
$length = ($length > $bytesLeft) ? $bytesLeft : $length;
$uploadResponse = $this->bosClient->uploadPartFromFile(
$bucket,
$key,
$uploadId,
$partNumber,
$fileName,
$offset,
$length);
array_push($partList, array(
'partNumber' => $partNumber,
'eTag' => $uploadResponse->metadata['etag'],
));
$offset += $length;
$partNumber++;
$bytesLeft -= $length;
}
// complete upload
$this->bosClient->completeMultipartUpload($bucket, $key, $uploadId, $partList);
} catch (\Exception $e) {
$this->bosClient->abortMultipartUpload($bucket, $key, $uploadId);
throw $e;
}
} | php | private function uploadMedia($fileName, $bucket, $key)
{
// init multi-part upload
$initUploadResponse = $this->bosClient->initiateMultipartUpload($bucket, $key);
$uploadId = $initUploadResponse->uploadId;
// do upload part
try {
$offset = 0;
$partNumber = 1;
$partSize = BosClient::MIN_PART_SIZE;
$length = $partSize;
$partList = array();
$bytesLeft = filesize($fileName);
while ($bytesLeft > 0) {
$length = ($length > $bytesLeft) ? $bytesLeft : $length;
$uploadResponse = $this->bosClient->uploadPartFromFile(
$bucket,
$key,
$uploadId,
$partNumber,
$fileName,
$offset,
$length);
array_push($partList, array(
'partNumber' => $partNumber,
'eTag' => $uploadResponse->metadata['etag'],
));
$offset += $length;
$partNumber++;
$bytesLeft -= $length;
}
// complete upload
$this->bosClient->completeMultipartUpload($bucket, $key, $uploadId, $partList);
} catch (\Exception $e) {
$this->bosClient->abortMultipartUpload($bucket, $key, $uploadId);
throw $e;
}
} | [
"private",
"function",
"uploadMedia",
"(",
"$",
"fileName",
",",
"$",
"bucket",
",",
"$",
"key",
")",
"{",
"// init multi-part upload",
"$",
"initUploadResponse",
"=",
"$",
"this",
"->",
"bosClient",
"->",
"initiateMultipartUpload",
"(",
"$",
"bucket",
",",
"$... | Upload the media source to bos.
@param $fileName
@param $bucket
@param $key
@throws \Exception | [
"Upload",
"the",
"media",
"source",
"to",
"bos",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Vod/VodClient.php#L995-L1035 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getSession | public function getSession($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/session/$sessionId"
);
} | php | public function getSession($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/session/$sessionId"
);
} | [
"public",
"function",
"getSession",
"(",
"$",
"sessionId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"e... | Get a session.
@param $sessionId string, session id
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed session detail
@throws BceClientException | [
"Get",
"a",
"session",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L198-L214 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.listSessions | public function listSessions($options = array())
{
list($config, $status, $marker, $maxSize) = $this->parseOptions($options, 'config', 'status', 'marker', 'maxSize');
$params = array();
if ($status !== null) {
$params['status'] = $status;
}
if ($marker !== null) {
$params['marker'] = $marker;
}
if ($maxSize !== null) {
$params['maxSize'] = $maxSize;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/session'
);
} | php | public function listSessions($options = array())
{
list($config, $status, $marker, $maxSize) = $this->parseOptions($options, 'config', 'status', 'marker', 'maxSize');
$params = array();
if ($status !== null) {
$params['status'] = $status;
}
if ($marker !== null) {
$params['marker'] = $marker;
}
if ($maxSize !== null) {
$params['maxSize'] = $maxSize;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/session'
);
} | [
"public",
"function",
"listSessions",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"status",
",",
"$",
"marker",
",",
"$",
"maxSize",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
... | List sessions.
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
status: session status, READY / ONGOING / PAUSED
marker: query marker.
maxSize: max number of listed sessions.
}
@return mixed session list | [
"List",
"sessions",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L326-L350 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.listSessionsByStatus | public function listSessionsByStatus($status, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($status)) {
throw new BceClientException("The parameter status "
. "should NOT be null or empty string");
}
$params = array(
'status' => $status,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/session'
);
} | php | public function listSessionsByStatus($status, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($status)) {
throw new BceClientException("The parameter status "
. "should NOT be null or empty string");
}
$params = array(
'status' => $status,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
'/session'
);
} | [
"public",
"function",
"listSessionsByStatus",
"(",
"$",
"status",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(... | List sessions with a status filter.
@param $status string, session status as a filter,
valid values: READY / ONGOING / PAUSED
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed session list
@throws BceClientException | [
"List",
"sessions",
"with",
"a",
"status",
"filter",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L365-L386 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.resumeSession | public function resumeSession($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
$params = array(
'resume' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/session/$sessionId"
);
} | php | public function resumeSession($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
$params = array(
'resume' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/session/$sessionId"
);
} | [
"public",
"function",
"resumeSession",
"(",
"$",
"sessionId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
... | Resume a session.
@param $sessionId string, session id
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Resume",
"a",
"session",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L471-L492 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.deleteSession | public function deleteSession($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/session/$sessionId"
);
} | php | public function deleteSession($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/session/$sessionId"
);
} | [
"public",
"function",
"deleteSession",
"(",
"$",
"sessionId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
... | Delete a session.
@param $sessionId string, session id
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Delete",
"a",
"session",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L541-L557 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.setCuepoint | public function setCuepoint($sessionId, $callback, $options = array())
{
list($config, $arguments) = $this->parseOptions(
$options,
'config',
'arguments'
);
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
if (empty($callback)) {
throw new BceClientException("The parameter callback "
. "should NOT be null or empty string");
}
$body = array();
$body['callback'] = $callback;
if ($arguments !== null) {
$body['arguments'] = $arguments;
}
$params = array(
'cuepoint' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
'body' => json_encode($body, JSON_FORCE_OBJECT),
),
"/session/$sessionId"
);
} | php | public function setCuepoint($sessionId, $callback, $options = array())
{
list($config, $arguments) = $this->parseOptions(
$options,
'config',
'arguments'
);
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
if (empty($callback)) {
throw new BceClientException("The parameter callback "
. "should NOT be null or empty string");
}
$body = array();
$body['callback'] = $callback;
if ($arguments !== null) {
$body['arguments'] = $arguments;
}
$params = array(
'cuepoint' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
'body' => json_encode($body, JSON_FORCE_OBJECT),
),
"/session/$sessionId"
);
} | [
"public",
"function",
"setCuepoint",
"(",
"$",
"sessionId",
",",
"$",
"callback",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"arguments",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"option... | Set cuepoint to session.
@param $sessionId string, session id
@param $callback string, callback method name
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
arguments: array, callback arguments
}
@return mixed
@throws BceClientException | [
"Set",
"cuepoint",
"to",
"session",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L573-L611 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getSessionSourceInfo | public function getSessionSourceInfo($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
$params = array(
'sourceInfo' => null,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/session/$sessionId"
);
} | php | public function getSessionSourceInfo($sessionId, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($sessionId)) {
throw new BceClientException("The parameter sessionId "
. "should NOT be null or empty string");
}
$params = array(
'sourceInfo' => null,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/session/$sessionId"
);
} | [
"public",
"function",
"getSessionSourceInfo",
"(",
"$",
"sessionId",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
... | Get session real-time source info.
@param $sessionId string, session id
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"session",
"real",
"-",
"time",
"source",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L701-L722 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.createPreset | public function createPreset($name, $options = array())
{
list($config, $description, $forwardOnly, $audio, $video, $hls, $rtmp) = $this->parseOptions(
$options,
'config',
'description',
'forwardOnly',
'audio',
'video',
'hls',
'rtmp'
);
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
$body = array(
'name' => $name,
);
if ($description !== null) {
$body['description'] = $description;
}
if ($forwardOnly !== null) {
$body['forwardOnly'] = $forwardOnly;
}
if ($audio !== null) {
$body['audio'] = $audio;
}
if ($video !== null) {
$body['video'] = $video;
}
if ($hls !== null) {
$body['hls'] = $hls;
}
if ($rtmp !== null) {
$body['rtmp'] = $rtmp;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/preset'
);
} | php | public function createPreset($name, $options = array())
{
list($config, $description, $forwardOnly, $audio, $video, $hls, $rtmp) = $this->parseOptions(
$options,
'config',
'description',
'forwardOnly',
'audio',
'video',
'hls',
'rtmp'
);
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
$body = array(
'name' => $name,
);
if ($description !== null) {
$body['description'] = $description;
}
if ($forwardOnly !== null) {
$body['forwardOnly'] = $forwardOnly;
}
if ($audio !== null) {
$body['audio'] = $audio;
}
if ($video !== null) {
$body['video'] = $video;
}
if ($hls !== null) {
$body['hls'] = $hls;
}
if ($rtmp !== null) {
$body['rtmp'] = $rtmp;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
'/preset'
);
} | [
"public",
"function",
"createPreset",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"description",
",",
"$",
"forwardOnly",
",",
"$",
"audio",
",",
"$",
"video",
",",
"$",
"hls",
",",... | Create a preset.
@param $name string, preset name
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
description: string, preset description
forwardOnly: boolean, whether the preset is forward-only.
when forwardOnly = true, should not set audio/video.
audio: { audio output settings
bitRateInBps: number, output audio bit rate
sampleRateInHz: number, output audio sample rate
channels: number, output audio
},
video: { video output settings
codec: string, output video codec, valid values: h264
codecOptions: {
profile: string, valid values: baseline/main/high
}
bitRateInBps: number, output video bit rate
maxFrameRate: number, output video max frame rate
maxWidthInPixel: number, output video max width
maxHeightInPixel: number, output video max height
sizingPolicy: string, output video sizing policy,
valid values: keep/stretch/shrinkToFit
},
hls: { hls output settings
segmentTimeInSecond: number, each hls segment time length
segmentListSize: number, length of segment list in the output m3u8
adaptive: boolean, whether adaptive hls is enabled
},
rmtp: { rmtp output settings
gopCache: boolean, whether or not cache 1 gop
}
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"preset",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L764-L813 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.