repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.orHaving
public function orHaving(...$conditions) : self { $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause( $this->havingConditions, 'OR', ...$this->createConditionExpressions($conditions) ); return $this; }
php
public function orHaving(...$conditions) : self { $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause( $this->havingConditions, 'OR', ...$this->createConditionExpressions($conditions) ); return $this; }
[ "public", "function", "orHaving", "(", "...", "$", "conditions", ")", ":", "self", "{", "$", "this", "->", "havingConditions", "=", "$", "this", "->", "conditionalQueryBuilder", "->", "addConditionToClause", "(", "$", "this", "->", "havingConditions", ",", "'O...
Adds to a "HAVING" condition that will be "OR"ed with other conditions @param array $conditions,... A variable list of conditions to be met @return self For method chaining
[ "Adds", "to", "a", "HAVING", "condition", "that", "will", "be", "OR", "ed", "with", "other", "conditions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L288-L295
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.rightJoin
public function rightJoin(string $tableName, string $tableAlias, string $condition) : self { $this->joins['right'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition]; return $this; }
php
public function rightJoin(string $tableName, string $tableAlias, string $condition) : self { $this->joins['right'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition]; return $this; }
[ "public", "function", "rightJoin", "(", "string", "$", "tableName", ",", "string", "$", "tableAlias", ",", "string", "$", "condition", ")", ":", "self", "{", "$", "this", "->", "joins", "[", "'right'", "]", "[", "]", "=", "[", "'tableName'", "=>", "$",...
Adds a right join to the query @param string $tableName The name of the table we're joining @param string $tableAlias The alias of the table name @param string $condition The "ON" portion of the join @return self For method chaining
[ "Adds", "a", "right", "join", "to", "the", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L334-L339
opulencephp/Opulence
src/Opulence/Ioc/Bootstrappers/Dispatchers/BootstrapperDispatcher.php
BootstrapperDispatcher.dispatchEagerly
private function dispatchEagerly(array $bootstrapperClasses, bool $run) { foreach ($bootstrapperClasses as $bootstrapperClass) { /** @var Bootstrapper $bootstrapper */ $bootstrapper = $this->bootstrapperResolver->resolve($bootstrapperClass); $this->bootstrapperObjects[] = $bootstrapper; $bootstrapper->registerBindings($this->container); } if ($run) { foreach ($this->bootstrapperObjects as $bootstrapper) { $this->container->callMethod($bootstrapper, 'run', [], true); } } }
php
private function dispatchEagerly(array $bootstrapperClasses, bool $run) { foreach ($bootstrapperClasses as $bootstrapperClass) { /** @var Bootstrapper $bootstrapper */ $bootstrapper = $this->bootstrapperResolver->resolve($bootstrapperClass); $this->bootstrapperObjects[] = $bootstrapper; $bootstrapper->registerBindings($this->container); } if ($run) { foreach ($this->bootstrapperObjects as $bootstrapper) { $this->container->callMethod($bootstrapper, 'run', [], true); } } }
[ "private", "function", "dispatchEagerly", "(", "array", "$", "bootstrapperClasses", ",", "bool", "$", "run", ")", "{", "foreach", "(", "$", "bootstrapperClasses", "as", "$", "bootstrapperClass", ")", "{", "/** @var Bootstrapper $bootstrapper */", "$", "bootstrapper", ...
Dispatches the registry eagerly @param array $bootstrapperClasses The list of bootstrapper classes to dispatch @param bool $run Whether or not to run the bootstrapper (deprecated) @throws RuntimeException Thrown if there was a problem dispatching the bootstrappers
[ "Dispatches", "the", "registry", "eagerly" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Bootstrappers/Dispatchers/BootstrapperDispatcher.php#L113-L127
opulencephp/Opulence
src/Opulence/Ioc/Bootstrappers/Dispatchers/BootstrapperDispatcher.php
BootstrapperDispatcher.dispatchLazily
private function dispatchLazily(array $boundClassesToBindingData, bool $run) { foreach ($boundClassesToBindingData as $boundClass => $bindingData) { $bootstrapperClass = $bindingData['bootstrapper']; $target = $bindingData['target']; $factory = function () use ($boundClass, $bootstrapperClass, $target, $run) { // To make sure this factory isn't used anymore to resolve the bound class, unbind it // Otherwise, we'd get into an infinite loop every time we tried to resolve it if ($target === null) { $this->container->unbind($boundClass); } else { $this->container->for($target, function (IContainer $container) use ($boundClass) { $container->unbind($boundClass); }); } $bootstrapper = $this->bootstrapperResolver->resolve($bootstrapperClass); if (!in_array($bootstrapper, $this->bootstrapperObjects)) { $this->bootstrapperObjects[] = $bootstrapper; } if (!isset($this->dispatchedBootstrappers[$bootstrapperClass])) { $bootstrapper->registerBindings($this->container); if ($run) { $this->container->callMethod($bootstrapper, 'run', [], true); } $this->dispatchedBootstrappers[$bootstrapperClass] = true; } if ($target === null) { return $this->container->resolve($boundClass); } else { return $this->container->for($target, function (IContainer $container) use ($boundClass) { return $container->resolve($boundClass); }); } }; if ($target === null) { $this->container->bindFactory($boundClass, $factory); } else { $this->container->for($target, function (IContainer $container) use ($boundClass, $factory) { $container->bindFactory($boundClass, $factory); }); } } }
php
private function dispatchLazily(array $boundClassesToBindingData, bool $run) { foreach ($boundClassesToBindingData as $boundClass => $bindingData) { $bootstrapperClass = $bindingData['bootstrapper']; $target = $bindingData['target']; $factory = function () use ($boundClass, $bootstrapperClass, $target, $run) { // To make sure this factory isn't used anymore to resolve the bound class, unbind it // Otherwise, we'd get into an infinite loop every time we tried to resolve it if ($target === null) { $this->container->unbind($boundClass); } else { $this->container->for($target, function (IContainer $container) use ($boundClass) { $container->unbind($boundClass); }); } $bootstrapper = $this->bootstrapperResolver->resolve($bootstrapperClass); if (!in_array($bootstrapper, $this->bootstrapperObjects)) { $this->bootstrapperObjects[] = $bootstrapper; } if (!isset($this->dispatchedBootstrappers[$bootstrapperClass])) { $bootstrapper->registerBindings($this->container); if ($run) { $this->container->callMethod($bootstrapper, 'run', [], true); } $this->dispatchedBootstrappers[$bootstrapperClass] = true; } if ($target === null) { return $this->container->resolve($boundClass); } else { return $this->container->for($target, function (IContainer $container) use ($boundClass) { return $container->resolve($boundClass); }); } }; if ($target === null) { $this->container->bindFactory($boundClass, $factory); } else { $this->container->for($target, function (IContainer $container) use ($boundClass, $factory) { $container->bindFactory($boundClass, $factory); }); } } }
[ "private", "function", "dispatchLazily", "(", "array", "$", "boundClassesToBindingData", ",", "bool", "$", "run", ")", "{", "foreach", "(", "$", "boundClassesToBindingData", "as", "$", "boundClass", "=>", "$", "bindingData", ")", "{", "$", "bootstrapperClass", "...
Dispatches the registry lazily @param array $boundClassesToBindingData The mapping of bound classes to their targets and bootstrappers @param bool $run Whether or not to run the bootstrapper (deprecated) @throws RuntimeException Thrown if there was a problem dispatching the bootstrappers
[ "Dispatches", "the", "registry", "lazily" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Bootstrappers/Dispatchers/BootstrapperDispatcher.php#L136-L186
opulencephp/Opulence
src/Opulence/Memcached/Types/TypeMapper.php
TypeMapper.fromMemcachedTimestamp
public function fromMemcachedTimestamp($timestamp) : DateTime { $date = DateTime::createFromFormat('U', $timestamp); $date->setTimezone(new DateTimeZone(date_default_timezone_get())); return $date; }
php
public function fromMemcachedTimestamp($timestamp) : DateTime { $date = DateTime::createFromFormat('U', $timestamp); $date->setTimezone(new DateTimeZone(date_default_timezone_get())); return $date; }
[ "public", "function", "fromMemcachedTimestamp", "(", "$", "timestamp", ")", ":", "DateTime", "{", "$", "date", "=", "DateTime", "::", "createFromFormat", "(", "'U'", ",", "$", "timestamp", ")", ";", "$", "date", "->", "setTimezone", "(", "new", "DateTimeZone...
Converts a Memcached Unix timestamp to a PHP timestamp @param int $timestamp The Unix timestamp to convert from @return DateTime The PHP timestamp
[ "Converts", "a", "Memcached", "Unix", "timestamp", "to", "a", "PHP", "timestamp" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Memcached/Types/TypeMapper.php#L39-L45
opulencephp/Opulence
src/Opulence/Authentication/Tokens/Signatures/RsaSsaPkcsSigner.php
RsaSsaPkcsSigner.getOpenSslAlgorithm
private function getOpenSslAlgorithm(string $algorithm) : int { switch ($algorithm) { case Algorithms::RSA_SHA256: return OPENSSL_ALGO_SHA256; case Algorithms::RSA_SHA384: return OPENSSL_ALGO_SHA384; case Algorithms::RSA_SHA512: return OPENSSL_ALGO_SHA512; default: throw new InvalidArgumentException("Algorithm \"$algorithm\" is not an OpenSSL algorithm"); } }
php
private function getOpenSslAlgorithm(string $algorithm) : int { switch ($algorithm) { case Algorithms::RSA_SHA256: return OPENSSL_ALGO_SHA256; case Algorithms::RSA_SHA384: return OPENSSL_ALGO_SHA384; case Algorithms::RSA_SHA512: return OPENSSL_ALGO_SHA512; default: throw new InvalidArgumentException("Algorithm \"$algorithm\" is not an OpenSSL algorithm"); } }
[ "private", "function", "getOpenSslAlgorithm", "(", "string", "$", "algorithm", ")", ":", "int", "{", "switch", "(", "$", "algorithm", ")", "{", "case", "Algorithms", "::", "RSA_SHA256", ":", "return", "OPENSSL_ALGO_SHA256", ";", "case", "Algorithms", "::", "RS...
Gets the OpenSSL Id for a algorithm @param string $algorithm The algorithm whose OpenSSL Id we want @return int The PHP Id for the algorithm @throws InvalidArgumentException Thrown if the algorithm is not an OpenSSL algorithm
[ "Gets", "the", "OpenSSL", "Id", "for", "a", "algorithm" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/Signatures/RsaSsaPkcsSigner.php#L92-L104
opulencephp/Opulence
src/Opulence/QueryBuilders/PostgreSql/AugmentingQueryBuilder.php
AugmentingQueryBuilder.addReturning
public function addReturning(string ...$expression) : self { $this->returningExpressions = array_merge($this->returningExpressions, $expression); return $this; }
php
public function addReturning(string ...$expression) : self { $this->returningExpressions = array_merge($this->returningExpressions, $expression); return $this; }
[ "public", "function", "addReturning", "(", "string", "...", "$", "expression", ")", ":", "self", "{", "$", "this", "->", "returningExpressions", "=", "array_merge", "(", "$", "this", "->", "returningExpressions", ",", "$", "expression", ")", ";", "return", "...
Adds to a "RETURNING" clause @param string[] $expression,... A variable list of expressions to add to the "RETURNING" clause @return self For method chaining
[ "Adds", "to", "a", "RETURNING", "clause" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/PostgreSql/AugmentingQueryBuilder.php#L29-L34
opulencephp/Opulence
src/Opulence/Framework/Console/Commands/FlushFrameworkCacheCommand.php
FlushFrameworkCacheCommand.flushBootstrapperCache
private function flushBootstrapperCache(IResponse $response) { $this->httpBootstrapperCache->flush(); $this->consoleBootstrapperCache->flush(); $response->writeln('<info>Bootstrapper cache flushed</info>'); }
php
private function flushBootstrapperCache(IResponse $response) { $this->httpBootstrapperCache->flush(); $this->consoleBootstrapperCache->flush(); $response->writeln('<info>Bootstrapper cache flushed</info>'); }
[ "private", "function", "flushBootstrapperCache", "(", "IResponse", "$", "response", ")", "{", "$", "this", "->", "httpBootstrapperCache", "->", "flush", "(", ")", ";", "$", "this", "->", "consoleBootstrapperCache", "->", "flush", "(", ")", ";", "$", "response"...
Flushes the bootstrapper cache @param IResponse $response The response to write to
[ "Flushes", "the", "bootstrapper", "cache" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Console/Commands/FlushFrameworkCacheCommand.php#L79-L85
opulencephp/Opulence
src/Opulence/Framework/Console/Commands/FlushFrameworkCacheCommand.php
FlushFrameworkCacheCommand.flushRouteCache
private function flushRouteCache(IResponse $response) { if (($path = Config::get('paths', 'routes.cache')) !== null) { $this->routeCache->flush("$path/" . RouteCache::DEFAULT_CACHED_ROUTES_FILE_NAME); } $response->writeln('<info>Route cache flushed</info>'); }
php
private function flushRouteCache(IResponse $response) { if (($path = Config::get('paths', 'routes.cache')) !== null) { $this->routeCache->flush("$path/" . RouteCache::DEFAULT_CACHED_ROUTES_FILE_NAME); } $response->writeln('<info>Route cache flushed</info>'); }
[ "private", "function", "flushRouteCache", "(", "IResponse", "$", "response", ")", "{", "if", "(", "(", "$", "path", "=", "Config", "::", "get", "(", "'paths'", ",", "'routes.cache'", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "routeCache", "...
Flushes the route cache @param IResponse $response The response to write to
[ "Flushes", "the", "route", "cache" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Console/Commands/FlushFrameworkCacheCommand.php#L92-L99
opulencephp/Opulence
src/Opulence/Framework/Http/Kernel.php
Kernel.handle
public function handle(Request $request) : Response { try { return (new Pipeline) ->send($request) ->through($this->convertMiddlewareToPipelineStages($this->getMiddleware()), 'handle') ->then(function ($request) { return $this->router->route($request); }) ->execute(); } catch (Exception $ex) { $this->setExceptionRendererVars($request); $this->exceptionHandler->handle($ex); return $this->exceptionRenderer->getResponse(); } catch (Throwable $ex) { $this->setExceptionRendererVars($request); $this->exceptionHandler->handle($ex); return $this->exceptionRenderer->getResponse(); } }
php
public function handle(Request $request) : Response { try { return (new Pipeline) ->send($request) ->through($this->convertMiddlewareToPipelineStages($this->getMiddleware()), 'handle') ->then(function ($request) { return $this->router->route($request); }) ->execute(); } catch (Exception $ex) { $this->setExceptionRendererVars($request); $this->exceptionHandler->handle($ex); return $this->exceptionRenderer->getResponse(); } catch (Throwable $ex) { $this->setExceptionRendererVars($request); $this->exceptionHandler->handle($ex); return $this->exceptionRenderer->getResponse(); } }
[ "public", "function", "handle", "(", "Request", "$", "request", ")", ":", "Response", "{", "try", "{", "return", "(", "new", "Pipeline", ")", "->", "send", "(", "$", "request", ")", "->", "through", "(", "$", "this", "->", "convertMiddlewareToPipelineStage...
Handles an HTTP request @param Request $request The HTTP request to handle @return Response The HTTP response
[ "Handles", "an", "HTTP", "request" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Http/Kernel.php#L131-L152
opulencephp/Opulence
src/Opulence/Framework/Http/Kernel.php
Kernel.convertMiddlewareToPipelineStages
protected function convertMiddlewareToPipelineStages(array $middleware) : array { $stages = []; foreach ($middleware as $singleMiddleware) { if ($singleMiddleware instanceof MiddlewareParameters) { /** @var MiddlewareParameters $singleMiddleware */ /** @var ParameterizedMiddleware $tempMiddleware */ $tempMiddleware = $this->container->resolve($singleMiddleware->getMiddlewareClassName()); $tempMiddleware->setParameters($singleMiddleware->getParameters()); $singleMiddleware = $tempMiddleware; } elseif (is_string($singleMiddleware)) { $singleMiddleware = $this->container->resolve($singleMiddleware); } $stages[] = $singleMiddleware; } return $stages; }
php
protected function convertMiddlewareToPipelineStages(array $middleware) : array { $stages = []; foreach ($middleware as $singleMiddleware) { if ($singleMiddleware instanceof MiddlewareParameters) { /** @var MiddlewareParameters $singleMiddleware */ /** @var ParameterizedMiddleware $tempMiddleware */ $tempMiddleware = $this->container->resolve($singleMiddleware->getMiddlewareClassName()); $tempMiddleware->setParameters($singleMiddleware->getParameters()); $singleMiddleware = $tempMiddleware; } elseif (is_string($singleMiddleware)) { $singleMiddleware = $this->container->resolve($singleMiddleware); } $stages[] = $singleMiddleware; } return $stages; }
[ "protected", "function", "convertMiddlewareToPipelineStages", "(", "array", "$", "middleware", ")", ":", "array", "{", "$", "stages", "=", "[", "]", ";", "foreach", "(", "$", "middleware", "as", "$", "singleMiddleware", ")", "{", "if", "(", "$", "singleMiddl...
Converts middleware to pipeline stages @param array $middleware The middleware to convert to pipeline stages @return callable[] The list of pipeline stages
[ "Converts", "middleware", "to", "pipeline", "stages" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Http/Kernel.php#L180-L199
opulencephp/Opulence
src/Opulence/Framework/Http/Kernel.php
Kernel.setExceptionRendererVars
private function setExceptionRendererVars(Request $request) { $this->exceptionRenderer->setRequest($request); if ($this->container->hasBinding(ICompiler::class)) { $this->exceptionRenderer->setViewCompiler($this->container->resolve(ICompiler::class)); } if ($this->container->hasBinding(IViewFactory::class)) { $this->exceptionRenderer->setViewFactory($this->container->resolve(IViewFactory::class)); } }
php
private function setExceptionRendererVars(Request $request) { $this->exceptionRenderer->setRequest($request); if ($this->container->hasBinding(ICompiler::class)) { $this->exceptionRenderer->setViewCompiler($this->container->resolve(ICompiler::class)); } if ($this->container->hasBinding(IViewFactory::class)) { $this->exceptionRenderer->setViewFactory($this->container->resolve(IViewFactory::class)); } }
[ "private", "function", "setExceptionRendererVars", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "exceptionRenderer", "->", "setRequest", "(", "$", "request", ")", ";", "if", "(", "$", "this", "->", "container", "->", "hasBinding", "(", "IComp...
Sets the variables in the exception renderer @param Request $request The current HTTP request
[ "Sets", "the", "variables", "in", "the", "exception", "renderer" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Http/Kernel.php#L206-L217
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.addRoute
public function addRoute(Route $route) : ParsedRoute { $route = $this->applyGroupSettings($route); $parsedRoute = $this->parser->parse($route); $this->routeCollection->add($parsedRoute); return $parsedRoute; }
php
public function addRoute(Route $route) : ParsedRoute { $route = $this->applyGroupSettings($route); $parsedRoute = $this->parser->parse($route); $this->routeCollection->add($parsedRoute); return $parsedRoute; }
[ "public", "function", "addRoute", "(", "Route", "$", "route", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "applyGroupSettings", "(", "$", "route", ")", ";", "$", "parsedRoute", "=", "$", "this", "->", "parser", "->", "parse", "(...
Adds a route to the router @param Route $route The route to add @return ParsedRoute The route with the group settings applied
[ "Adds", "a", "route", "to", "the", "router" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L67-L74
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.any
public function any(string $path, $controller, array $options = []) : array { return $this->multiple(RouteCollection::getMethods(), $path, $controller, $options); }
php
public function any(string $path, $controller, array $options = []) : array { return $this->multiple(RouteCollection::getMethods(), $path, $controller, $options); }
[ "public", "function", "any", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "return", "$", "this", "->", "multiple", "(", "RouteCollection", "::", "getMethods", "(", ")", ",", ...
Adds a route for the any method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute[] The list of generated routes
[ "Adds", "a", "route", "for", "the", "any", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L84-L87
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.delete
public function delete(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::DELETE, $path, $controller, $options); return $this->addRoute($route); }
php
public function delete(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::DELETE, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "delete", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "DELETE", "...
Adds a route for the DELETE method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "DELETE", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L97-L102
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.get
public function get(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::GET, $path, $controller, $options); return $this->addRoute($route); }
php
public function get(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::GET, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "get", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "GET", ",", ...
Adds a route for the GET method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "GET", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L112-L117
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.group
public function group(array $options, callable $callback) { array_push($this->groupOptionsStack, $options); $callback($this); array_pop($this->groupOptionsStack); }
php
public function group(array $options, callable $callback) { array_push($this->groupOptionsStack, $options); $callback($this); array_pop($this->groupOptionsStack); }
[ "public", "function", "group", "(", "array", "$", "options", ",", "callable", "$", "callback", ")", "{", "array_push", "(", "$", "this", "->", "groupOptionsStack", ",", "$", "options", ")", ";", "$", "callback", "(", "$", "this", ")", ";", "array_pop", ...
Groups similar routes together so that you don't have to repeat route options @param array $options The list of options common to all routes added in the closure It can contain the following keys: "path" => The common path to be prepended to all the grouped routes, "middleware" => The middleware to be added to all the grouped routes, "https" => Whether or not all the grouped routes are HTTPS, "vars" => The list of path variable regular expressions all the routes must match @param callable $callback A function that adds routes to the router
[ "Groups", "similar", "routes", "together", "so", "that", "you", "don", "t", "have", "to", "repeat", "route", "options" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L156-L161
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.head
public function head(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::HEAD, $path, $controller, $options); return $this->addRoute($route); }
php
public function head(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::HEAD, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "head", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "HEAD", ",", ...
Adds a route for the HEAD method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "HEAD", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L171-L176
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.multiple
public function multiple(array $methods, string $path, $controller, array $options = []) : array { $routes = []; foreach ($methods as $method) { $route = $this->createRoute($method, $path, $controller, $options); $parsedRoute = $this->addRoute($route); $routes[] = $parsedRoute; } return $routes; }
php
public function multiple(array $methods, string $path, $controller, array $options = []) : array { $routes = []; foreach ($methods as $method) { $route = $this->createRoute($method, $path, $controller, $options); $parsedRoute = $this->addRoute($route); $routes[] = $parsedRoute; } return $routes; }
[ "public", "function", "multiple", "(", "array", "$", "methods", ",", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "method...
Adds a route for multiple methods @param array $methods The list of methods to match on @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute[] The list of routes generated
[ "Adds", "a", "route", "for", "multiple", "methods" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L187-L198
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.options
public function options(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::OPTIONS, $path, $controller, $options); return $this->addRoute($route); }
php
public function options(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::OPTIONS, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "options", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "OPTIONS", ...
Adds a route for the OPTIONS method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "OPTIONS", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L208-L213
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.patch
public function patch(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::PATCH, $path, $controller, $options); return $this->addRoute($route); }
php
public function patch(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::PATCH, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "patch", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "PATCH", ","...
Adds a route for the PATCH method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "PATCH", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L223-L228
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.post
public function post(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::POST, $path, $controller, $options); return $this->addRoute($route); }
php
public function post(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::POST, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "post", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "POST", ",", ...
Adds a route for the POST method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "POST", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L238-L243
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.put
public function put(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::PUT, $path, $controller, $options); return $this->addRoute($route); }
php
public function put(string $path, $controller, array $options = []) : ParsedRoute { $route = $this->createRoute(RequestMethods::PUT, $path, $controller, $options); return $this->addRoute($route); }
[ "public", "function", "put", "(", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ParsedRoute", "{", "$", "route", "=", "$", "this", "->", "createRoute", "(", "RequestMethods", "::", "PUT", ",", ...
Adds a route for the PUT method at the given path @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return ParsedRoute The generated route
[ "Adds", "a", "route", "for", "the", "PUT", "method", "at", "the", "given", "path" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L253-L258
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.route
public function route(Request $request) : Response { $method = $request->getMethod(); /** @var ParsedRoute $route */ foreach ($this->routeCollection->get($method) as $route) { $compiledRoute = $this->compiler->compile($route, $request); if ($compiledRoute->isMatch()) { $this->matchedRoute = $compiledRoute; return $this->dispatcher->dispatch($this->matchedRoute, $request, $this->matchedController); } } // If we've gotten here, we've got a missing route throw new HttpException(404); }
php
public function route(Request $request) : Response { $method = $request->getMethod(); /** @var ParsedRoute $route */ foreach ($this->routeCollection->get($method) as $route) { $compiledRoute = $this->compiler->compile($route, $request); if ($compiledRoute->isMatch()) { $this->matchedRoute = $compiledRoute; return $this->dispatcher->dispatch($this->matchedRoute, $request, $this->matchedController); } } // If we've gotten here, we've got a missing route throw new HttpException(404); }
[ "public", "function", "route", "(", "Request", "$", "request", ")", ":", "Response", "{", "$", "method", "=", "$", "request", "->", "getMethod", "(", ")", ";", "/** @var ParsedRoute $route */", "foreach", "(", "$", "this", "->", "routeCollection", "->", "get...
Routes a request @param Request $request The request to route @return Response The response from the controller @throws RouteException Thrown if the controller or method could not be called @throws HttpException Thrown if there was no matching route
[ "Routes", "a", "request" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L268-L285
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.applyGroupSettings
private function applyGroupSettings(Route $route) : Route { $route->setRawPath($this->getGroupPath() . $route->getRawPath()); $route->setRawHost($this->getGroupHost() . $route->getRawHost()); if (!$route->usesCallable()) { $route->setControllerName($this->getGroupControllerNamespace() . $route->getControllerName()); } $route->setSecure($this->groupIsSecure() || $route->isSecure()); // The route's variable regexes take precedence over group regexes $route->setVarRegexes(array_merge($this->getVarRegexes(), $route->getVarRegexes())); $groupMiddleware = $this->getGroupMiddleware(); if (count($groupMiddleware) > 0) { $route->addMiddleware($groupMiddleware, true); } return $route; }
php
private function applyGroupSettings(Route $route) : Route { $route->setRawPath($this->getGroupPath() . $route->getRawPath()); $route->setRawHost($this->getGroupHost() . $route->getRawHost()); if (!$route->usesCallable()) { $route->setControllerName($this->getGroupControllerNamespace() . $route->getControllerName()); } $route->setSecure($this->groupIsSecure() || $route->isSecure()); // The route's variable regexes take precedence over group regexes $route->setVarRegexes(array_merge($this->getVarRegexes(), $route->getVarRegexes())); $groupMiddleware = $this->getGroupMiddleware(); if (count($groupMiddleware) > 0) { $route->addMiddleware($groupMiddleware, true); } return $route; }
[ "private", "function", "applyGroupSettings", "(", "Route", "$", "route", ")", ":", "Route", "{", "$", "route", "->", "setRawPath", "(", "$", "this", "->", "getGroupPath", "(", ")", ".", "$", "route", "->", "getRawPath", "(", ")", ")", ";", "$", "route"...
Applies any group settings to a route @param Route $route The route to apply the settings to @return Route The route with the applied settings
[ "Applies", "any", "group", "settings", "to", "a", "route" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L301-L320
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.createRoute
private function createRoute(string $method, string $path, $controller, array $options = []) : Route { return new Route([$method], $path, $controller, $options); }
php
private function createRoute(string $method, string $path, $controller, array $options = []) : Route { return new Route([$method], $path, $controller, $options); }
[ "private", "function", "createRoute", "(", "string", "$", "method", ",", "string", "$", "path", ",", "$", "controller", ",", "array", "$", "options", "=", "[", "]", ")", ":", "Route", "{", "return", "new", "Route", "(", "[", "$", "method", "]", ",", ...
Creates a route from the input @param string $method The method whose route this is @param string $path The path to match on @param string|callable $controller The name of the controller/method or the callback @param array $options The list of options for this path @return Route The route from the input
[ "Creates", "a", "route", "from", "the", "input" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L331-L334
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.getGroupControllerNamespace
private function getGroupControllerNamespace() : string { $controllerNamespace = ''; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['controllerNamespace'])) { // Add trailing slashes if they're not there already if (mb_substr($groupOptions['controllerNamespace'], -1) !== '\\') { $groupOptions['controllerNamespace'] .= '\\'; } $controllerNamespace .= $groupOptions['controllerNamespace']; } } return $controllerNamespace; }
php
private function getGroupControllerNamespace() : string { $controllerNamespace = ''; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['controllerNamespace'])) { // Add trailing slashes if they're not there already if (mb_substr($groupOptions['controllerNamespace'], -1) !== '\\') { $groupOptions['controllerNamespace'] .= '\\'; } $controllerNamespace .= $groupOptions['controllerNamespace']; } } return $controllerNamespace; }
[ "private", "function", "getGroupControllerNamespace", "(", ")", ":", "string", "{", "$", "controllerNamespace", "=", "''", ";", "foreach", "(", "$", "this", "->", "groupOptionsStack", "as", "$", "groupOptions", ")", "{", "if", "(", "isset", "(", "$", "groupO...
Gets the controller namespace from the current group stack @return string The controller namespace
[ "Gets", "the", "controller", "namespace", "from", "the", "current", "group", "stack" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L341-L357
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.getGroupHost
private function getGroupHost() : string { $host = ''; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['host'])) { $host = $groupOptions['host'] . $host; } } return $host; }
php
private function getGroupHost() : string { $host = ''; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['host'])) { $host = $groupOptions['host'] . $host; } } return $host; }
[ "private", "function", "getGroupHost", "(", ")", ":", "string", "{", "$", "host", "=", "''", ";", "foreach", "(", "$", "this", "->", "groupOptionsStack", "as", "$", "groupOptions", ")", "{", "if", "(", "isset", "(", "$", "groupOptions", "[", "'host'", ...
Gets the host from the current group stack @return string The host
[ "Gets", "the", "host", "from", "the", "current", "group", "stack" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L364-L375
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.getGroupMiddleware
private function getGroupMiddleware() : array { $middleware = []; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['middleware'])) { if (!is_array($groupOptions['middleware'])) { $groupOptions['middleware'] = [$groupOptions['middleware']]; } $middleware = array_merge($middleware, $groupOptions['middleware']); } } return $middleware; }
php
private function getGroupMiddleware() : array { $middleware = []; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['middleware'])) { if (!is_array($groupOptions['middleware'])) { $groupOptions['middleware'] = [$groupOptions['middleware']]; } $middleware = array_merge($middleware, $groupOptions['middleware']); } } return $middleware; }
[ "private", "function", "getGroupMiddleware", "(", ")", ":", "array", "{", "$", "middleware", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "groupOptionsStack", "as", "$", "groupOptions", ")", "{", "if", "(", "isset", "(", "$", "groupOptions", "[...
Gets the middleware in the current group stack @return array The list of middleware of all the groups
[ "Gets", "the", "middleware", "in", "the", "current", "group", "stack" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L382-L397
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.getGroupPath
private function getGroupPath() : string { $path = ''; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['path'])) { $path .= $groupOptions['path']; } } return $path; }
php
private function getGroupPath() : string { $path = ''; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['path'])) { $path .= $groupOptions['path']; } } return $path; }
[ "private", "function", "getGroupPath", "(", ")", ":", "string", "{", "$", "path", "=", "''", ";", "foreach", "(", "$", "this", "->", "groupOptionsStack", "as", "$", "groupOptions", ")", "{", "if", "(", "isset", "(", "$", "groupOptions", "[", "'path'", ...
Gets the path of the current group stack @return string The path of all the groups concatenated together
[ "Gets", "the", "path", "of", "the", "current", "group", "stack" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L404-L415
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.getVarRegexes
private function getVarRegexes() : array { $variableRegexes = []; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['vars'])) { $variableRegexes = array_merge($variableRegexes, $groupOptions['vars']); } } return $variableRegexes; }
php
private function getVarRegexes() : array { $variableRegexes = []; foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['vars'])) { $variableRegexes = array_merge($variableRegexes, $groupOptions['vars']); } } return $variableRegexes; }
[ "private", "function", "getVarRegexes", "(", ")", ":", "array", "{", "$", "variableRegexes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "groupOptionsStack", "as", "$", "groupOptions", ")", "{", "if", "(", "isset", "(", "$", "groupOptions", "[...
Gets the variable regexes from the current group stack @return array The The mapping of variable names to regexes
[ "Gets", "the", "variable", "regexes", "from", "the", "current", "group", "stack" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L422-L433
opulencephp/Opulence
src/Opulence/Routing/Router.php
Router.groupIsSecure
private function groupIsSecure() : bool { foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['https']) && $groupOptions['https']) { return true; } } return false; }
php
private function groupIsSecure() : bool { foreach ($this->groupOptionsStack as $groupOptions) { if (isset($groupOptions['https']) && $groupOptions['https']) { return true; } } return false; }
[ "private", "function", "groupIsSecure", "(", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "groupOptionsStack", "as", "$", "groupOptions", ")", "{", "if", "(", "isset", "(", "$", "groupOptions", "[", "'https'", "]", ")", "&&", "$", "groupOpti...
Gets whether or not the current group stack is secure If ANY of the groups were marked as HTTPS, then this will return true even if a sub-group is not marked HTTPS @return bool True if the group is secure, otherwise false
[ "Gets", "whether", "or", "not", "the", "current", "group", "stack", "is", "secure", "If", "ANY", "of", "the", "groups", "were", "marked", "as", "HTTPS", "then", "this", "will", "return", "true", "even", "if", "a", "sub", "-", "group", "is", "not", "mar...
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Router.php#L441-L450
char0n/ffmpeg-php
src/Frame.php
Frame.crop
public function crop($cropTop, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) { $this->resize($this->getWidth(), $this->getHeight(), $cropTop, $cropBottom, $cropLeft, $cropRight); }
php
public function crop($cropTop, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) { $this->resize($this->getWidth(), $this->getHeight(), $cropTop, $cropBottom, $cropLeft, $cropRight); }
[ "public", "function", "crop", "(", "$", "cropTop", ",", "$", "cropBottom", "=", "0", ",", "$", "cropLeft", "=", "0", ",", "$", "cropRight", "=", "0", ")", "{", "$", "this", "->", "resize", "(", "$", "this", "->", "getWidth", "(", ")", ",", "$", ...
Crop the frame. NOTE: Crop values must be even numbers. @param int $cropTop Rows of pixels removed from the top of the frame. @param int $cropBottom Rows of pixels removed from the bottom of the frame. @param int $cropLeft Rows of pixels removed from the left of the frame. @param int $cropRight Rows of pixels removed from the right of the frame. @return void
[ "Crop", "the", "frame", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Frame.php#L110-L113
char0n/ffmpeg-php
src/Frame.php
Frame.resize
public function resize($width, $height, $cropTop = 0, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) { $widthCrop = ($cropLeft + $cropRight); $heightCrop = ($cropTop + $cropBottom); $width -= $widthCrop; $height -= $heightCrop; $resizedImage = imagecreatetruecolor($width, $height); $gdImage = $this->toGDImage(); imagecopyresampled( $resizedImage, $gdImage, 0, 0, $cropLeft, $cropTop, $width, $height, $this->getWidth() - $widthCrop, $this->getHeight() - $heightCrop ); imageconvolution( $resizedImage, [ [-1, -1, -1], [-1, 24, -1], [-1, -1, -1], ], 16, 0 ); $this->gdImageData = $this->gdImageToBinaryData($resizedImage); $this->width = imagesx($resizedImage); $this->height = imagesy($resizedImage); imagedestroy($gdImage); imagedestroy($resizedImage); }
php
public function resize($width, $height, $cropTop = 0, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) { $widthCrop = ($cropLeft + $cropRight); $heightCrop = ($cropTop + $cropBottom); $width -= $widthCrop; $height -= $heightCrop; $resizedImage = imagecreatetruecolor($width, $height); $gdImage = $this->toGDImage(); imagecopyresampled( $resizedImage, $gdImage, 0, 0, $cropLeft, $cropTop, $width, $height, $this->getWidth() - $widthCrop, $this->getHeight() - $heightCrop ); imageconvolution( $resizedImage, [ [-1, -1, -1], [-1, 24, -1], [-1, -1, -1], ], 16, 0 ); $this->gdImageData = $this->gdImageToBinaryData($resizedImage); $this->width = imagesx($resizedImage); $this->height = imagesy($resizedImage); imagedestroy($gdImage); imagedestroy($resizedImage); }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "cropTop", "=", "0", ",", "$", "cropBottom", "=", "0", ",", "$", "cropLeft", "=", "0", ",", "$", "cropRight", "=", "0", ")", "{", "$", "widthCrop", "=", "(", "$", ...
Resize and optionally crop the frame. (Cropping is built into ffmpeg resizing so I'm providing it here for completeness.) NOTE: Cropping is always applied to the frame before it is resized. Crop values must be even numbers. @param int $width New width of the frame (must be an even number). @param int $height New height of the frame (must be an even number). @param int $cropTop Rows of pixels removed from the top of the frame. @param int $cropBottom Rows of pixels removed from the bottom of the frame. @param int $cropLeft Rows of pixels removed from the left of the frame. @param int $cropRight Rows of pixels removed from the right of the frame. @return void
[ "Resize", "and", "optionally", "crop", "the", "frame", ".", "(", "Cropping", "is", "built", "into", "ffmpeg", "resizing", "so", "I", "m", "providing", "it", "here", "for", "completeness", ".", ")" ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Frame.php#L130-L166
char0n/ffmpeg-php
src/Frame.php
Frame.serialize
public function serialize() { $data = [ $this->gdImageData, $this->pts, $this->width, $this->height, ]; return serialize($data); }
php
public function serialize() { $data = [ $this->gdImageData, $this->pts, $this->width, $this->height, ]; return serialize($data); }
[ "public", "function", "serialize", "(", ")", "{", "$", "data", "=", "[", "$", "this", "->", "gdImageData", ",", "$", "this", "->", "pts", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "]", ";", "return", "serialize", "(", ...
Return string representation of a Frame. @return string The string representation of the object or null.
[ "Return", "string", "representation", "of", "a", "Frame", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Frame.php#L203-L213
char0n/ffmpeg-php
src/Frame.php
Frame.unserialize
public function unserialize($serialized) { list( $this->gdImageData, $this->pts, $this->width, $this->height ) = unserialize($serialized); }
php
public function unserialize($serialized) { list( $this->gdImageData, $this->pts, $this->width, $this->height ) = unserialize($serialized); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "list", "(", "$", "this", "->", "gdImageData", ",", "$", "this", "->", "pts", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", "=", "unserialize", "(", "$",...
Constructs the Frame from serialized data. @param string $serialized The string representation of Frame instance. @return void
[ "Constructs", "the", "Frame", "from", "serialized", "data", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Frame.php#L222-L230
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.addFrame
public function addFrame(Frame $frame) { $tmpFrame = clone $frame; $tmpFrame->resize($this->width, $this->height); ob_start(); imagegif($tmpFrame->toGDImage()); $this->frames[] = ob_get_clean(); $tmpFrame = null; }
php
public function addFrame(Frame $frame) { $tmpFrame = clone $frame; $tmpFrame->resize($this->width, $this->height); ob_start(); imagegif($tmpFrame->toGDImage()); $this->frames[] = ob_get_clean(); $tmpFrame = null; }
[ "public", "function", "addFrame", "(", "Frame", "$", "frame", ")", "{", "$", "tmpFrame", "=", "clone", "$", "frame", ";", "$", "tmpFrame", "->", "resize", "(", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", ";", "ob_start", "(", ...
Add a frame to the end of the animated gif. @param Frame $frame Frame to add.
[ "Add", "a", "frame", "to", "the", "end", "of", "the", "animated", "gif", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L92-L100
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.addGifHeader
protected function addGifHeader() { if (ord($this->frames[0]{10}) & 0x80) { $cMap = 3 * (2 << (ord($this->frames[0]{10}) & 0x07)); $this->gifData = 'GIF89a'; $this->gifData .= substr($this->frames[0], 6, 7); $this->gifData .= substr($this->frames[0], 13, $cMap); $this->gifData .= "!\377\13NETSCAPE2.0\3\1".$this->getGifWord($this->loopCount)."\0"; } }
php
protected function addGifHeader() { if (ord($this->frames[0]{10}) & 0x80) { $cMap = 3 * (2 << (ord($this->frames[0]{10}) & 0x07)); $this->gifData = 'GIF89a'; $this->gifData .= substr($this->frames[0], 6, 7); $this->gifData .= substr($this->frames[0], 13, $cMap); $this->gifData .= "!\377\13NETSCAPE2.0\3\1".$this->getGifWord($this->loopCount)."\0"; } }
[ "protected", "function", "addGifHeader", "(", ")", "{", "if", "(", "ord", "(", "$", "this", "->", "frames", "[", "0", "]", "{", "10", "}", ")", "&", "0x80", ")", "{", "$", "cMap", "=", "3", "*", "(", "2", "<<", "(", "ord", "(", "$", "this", ...
Adding header to the animation. @return void
[ "Adding", "header", "to", "the", "animation", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L107-L117
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.addFrameData
protected function addFrameData($i, $d) { $dis = 2; $col = 0; $localsString = 13 + 3 * (2 << (ord($this->frames[$i]{10}) & 0x07)); $localsEnd = strlen($this->frames[$i]) - $localsString - 1; $localsTmp = substr($this->frames[$i], $localsString, $localsEnd); $globalLength = 2 << (ord($this->frames[0]{10}) & 0x07); $localsLength = 2 << (ord($this->frames[$i]{10}) & 0x07); $globalRbg = substr($this->frames[0], 13, 3 * (2 << (ord($this->frames[0]{10}) & 0x07))); $localsRgb = substr($this->frames[$i], 13, 3 * (2 << (ord($this->frames[$i]{10}) & 0x07))); $localsExt = "!\xF9\x04".chr(($dis << 2) + 0).chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF)."\x0\x0"; $localsImg = null; if ($col > -1 && ord($this->frames[$i]{10}) & 0x80) { for ($j = 0; $j < (2 << (ord($this->frames[$i]{10}) & 0x07)); $j++) { if (ord($localsRgb{3 * $j + 0}) === (($col >> 16) & 0xFF) && ord($localsRgb{3 * $j + 1}) === (($col >> 8) & 0xFF) && ord($localsRgb{3 * $j + 2}) === (($col >> 0) & 0xFF) ) { $localsExt = "!\xF9\x04".chr(($dis << 2) + 1).chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF).chr( $j )."\x0"; break; } } } switch ($localsTmp{0}) { case '!': $localsImg = substr($localsTmp, 8, 10); $localsTmp = substr($localsTmp, 18); break; case ',': $localsImg = substr($localsTmp, 0, 10); $localsTmp = substr($localsTmp, 10); break; } if ($this->counter > -1 && ord($this->frames[$i]{10}) & 0x80) { if ($globalLength === $localsLength) { if ($this->gifBlockCompare($globalRbg, $localsRgb, $globalLength)) { $this->gifData .= ($localsExt.$localsImg.$localsTmp); } else { $byte = ord($localsImg{9}); $byte |= 0x80; $byte &= 0xF8; $byte |= (ord($this->frames[0]{10}) & 0x07); $localsImg{9} = chr($byte); $this->gifData .= ($localsExt.$localsImg.$localsRgb.$localsTmp); } } else { $byte = ord($localsImg{9}); $byte |= 0x80; $byte &= 0xF8; $byte |= (ord($this->frames[$i]{10}) & 0x07); $localsImg{9} = chr($byte); $this->gifData .= ($localsExt.$localsImg.$localsRgb.$localsTmp); } } else { $this->gifData .= ($localsExt.$localsImg.$localsTmp); } $this->counter = 1; }
php
protected function addFrameData($i, $d) { $dis = 2; $col = 0; $localsString = 13 + 3 * (2 << (ord($this->frames[$i]{10}) & 0x07)); $localsEnd = strlen($this->frames[$i]) - $localsString - 1; $localsTmp = substr($this->frames[$i], $localsString, $localsEnd); $globalLength = 2 << (ord($this->frames[0]{10}) & 0x07); $localsLength = 2 << (ord($this->frames[$i]{10}) & 0x07); $globalRbg = substr($this->frames[0], 13, 3 * (2 << (ord($this->frames[0]{10}) & 0x07))); $localsRgb = substr($this->frames[$i], 13, 3 * (2 << (ord($this->frames[$i]{10}) & 0x07))); $localsExt = "!\xF9\x04".chr(($dis << 2) + 0).chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF)."\x0\x0"; $localsImg = null; if ($col > -1 && ord($this->frames[$i]{10}) & 0x80) { for ($j = 0; $j < (2 << (ord($this->frames[$i]{10}) & 0x07)); $j++) { if (ord($localsRgb{3 * $j + 0}) === (($col >> 16) & 0xFF) && ord($localsRgb{3 * $j + 1}) === (($col >> 8) & 0xFF) && ord($localsRgb{3 * $j + 2}) === (($col >> 0) & 0xFF) ) { $localsExt = "!\xF9\x04".chr(($dis << 2) + 1).chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF).chr( $j )."\x0"; break; } } } switch ($localsTmp{0}) { case '!': $localsImg = substr($localsTmp, 8, 10); $localsTmp = substr($localsTmp, 18); break; case ',': $localsImg = substr($localsTmp, 0, 10); $localsTmp = substr($localsTmp, 10); break; } if ($this->counter > -1 && ord($this->frames[$i]{10}) & 0x80) { if ($globalLength === $localsLength) { if ($this->gifBlockCompare($globalRbg, $localsRgb, $globalLength)) { $this->gifData .= ($localsExt.$localsImg.$localsTmp); } else { $byte = ord($localsImg{9}); $byte |= 0x80; $byte &= 0xF8; $byte |= (ord($this->frames[0]{10}) & 0x07); $localsImg{9} = chr($byte); $this->gifData .= ($localsExt.$localsImg.$localsRgb.$localsTmp); } } else { $byte = ord($localsImg{9}); $byte |= 0x80; $byte &= 0xF8; $byte |= (ord($this->frames[$i]{10}) & 0x07); $localsImg{9} = chr($byte); $this->gifData .= ($localsExt.$localsImg.$localsRgb.$localsTmp); } } else { $this->gifData .= ($localsExt.$localsImg.$localsTmp); } $this->counter = 1; }
[ "protected", "function", "addFrameData", "(", "$", "i", ",", "$", "d", ")", "{", "$", "dis", "=", "2", ";", "$", "col", "=", "0", ";", "$", "localsString", "=", "13", "+", "3", "*", "(", "2", "<<", "(", "ord", "(", "$", "this", "->", "frames"...
Adding frame binary data to the animation. @param int $i Index of frame from AnimatedGif::frame array. @param int $d Delay (5 seconds = 500 delay units). @return void
[ "Adding", "frame", "binary", "data", "to", "the", "animation", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L127-L193
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.gifBlockCompare
protected function gifBlockCompare($globalBlock, $localBlock, $len) { for ($i = 0; $i < $len; $i++) { if ($globalBlock{3 * $i + 0} !== $localBlock{3 * $i + 0} || $globalBlock{3 * $i + 1} !== $localBlock{3 * $i + 1} || $globalBlock{3 * $i + 2} !== $localBlock{3 * $i + 2} ) { return false; } } return true; }
php
protected function gifBlockCompare($globalBlock, $localBlock, $len) { for ($i = 0; $i < $len; $i++) { if ($globalBlock{3 * $i + 0} !== $localBlock{3 * $i + 0} || $globalBlock{3 * $i + 1} !== $localBlock{3 * $i + 1} || $globalBlock{3 * $i + 2} !== $localBlock{3 * $i + 2} ) { return false; } } return true; }
[ "protected", "function", "gifBlockCompare", "(", "$", "globalBlock", ",", "$", "localBlock", ",", "$", "len", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "if", "(", "$", "globalBlock", ...
Gif compare block. @param string $globalBlock @param string $localBlock @param int $len @return bool
[ "Gif", "compare", "block", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L227-L239
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.save
public function save() { // No images to process if (0 === count($this->frames)) { return false; } return (boolean)file_put_contents($this->outFilePath, $this->getAnimation(), LOCK_EX); }
php
public function save() { // No images to process if (0 === count($this->frames)) { return false; } return (boolean)file_put_contents($this->outFilePath, $this->getAnimation(), LOCK_EX); }
[ "public", "function", "save", "(", ")", "{", "// No images to process", "if", "(", "0", "===", "count", "(", "$", "this", "->", "frames", ")", ")", "{", "return", "false", ";", "}", "return", "(", "boolean", ")", "file_put_contents", "(", "$", "this", ...
Saving animated gif to remote file. @return boolean
[ "Saving", "animated", "gif", "to", "remote", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L246-L254
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.getAnimation
public function getAnimation() { // No images to process. if (0 === count($this->frames)) { return false; } // Process images as animation. $this->addGifHeader(); for ($i = 0, $frameCount = count($this->frames); $i < $frameCount; $i++) { $this->addFrameData($i, 1 / $this->frameRate * 100); } $this->addGifFooter(); return $this->gifData; }
php
public function getAnimation() { // No images to process. if (0 === count($this->frames)) { return false; } // Process images as animation. $this->addGifHeader(); for ($i = 0, $frameCount = count($this->frames); $i < $frameCount; $i++) { $this->addFrameData($i, 1 / $this->frameRate * 100); } $this->addGifFooter(); return $this->gifData; }
[ "public", "function", "getAnimation", "(", ")", "{", "// No images to process.", "if", "(", "0", "===", "count", "(", "$", "this", "->", "frames", ")", ")", "{", "return", "false", ";", "}", "// Process images as animation.", "$", "this", "->", "addGifHeader",...
Getting animation binary data. @return string|boolean
[ "Getting", "animation", "binary", "data", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L261-L276
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.serialize
public function serialize() { return serialize( [ $this->outFilePath, $this->width, $this->height, $this->frameRate, $this->loopCount, $this->gifData, $this->frames, $this->counter, ] ); }
php
public function serialize() { return serialize( [ $this->outFilePath, $this->width, $this->height, $this->frameRate, $this->loopCount, $this->gifData, $this->frames, $this->counter, ] ); }
[ "public", "function", "serialize", "(", ")", "{", "return", "serialize", "(", "[", "$", "this", "->", "outFilePath", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "this", "->", "frameRate", ",", "$", "this", "->", "loop...
String representation of an AnimatedGif. @return string The string representation of the object or null.
[ "String", "representation", "of", "an", "AnimatedGif", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L283-L297
char0n/ffmpeg-php
src/AnimatedGif.php
AnimatedGif.unserialize
public function unserialize($serialized) { list( $this->outFilePath, $this->width, $this->height, $this->frameRate, $this->loopCount, $this->gifData, $this->frames, $this->counter ) = unserialize($serialized); }
php
public function unserialize($serialized) { list( $this->outFilePath, $this->width, $this->height, $this->frameRate, $this->loopCount, $this->gifData, $this->frames, $this->counter ) = unserialize($serialized); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "list", "(", "$", "this", "->", "outFilePath", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "this", "->", "frameRate", ",", "$", "this", "->", "loo...
Constructs the AnimatedGif. @param string $serialized The string representation of the object. @return void
[ "Constructs", "the", "AnimatedGif", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/AnimatedGif.php#L306-L318
char0n/ffmpeg-php
src/OutputProviders/FFProbeProvider.php
FFProbeProvider.getOutput
public function getOutput() { // Persistent opening if (true === $this->persistent && array_key_exists(get_class($this).$this->binary.$this->movieFile, self::$persistentBuffer) ) { return self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile]; } // File doesn't exist if (!file_exists($this->movieFile)) { throw new \UnexpectedValueException('Movie file not found', self::$EX_CODE_FILE_NOT_FOUND); } // Get information about file from ffprobe $output = []; exec($this->binary.' '.escapeshellarg($this->movieFile).' 2>&1', $output, $retVar); $output = implode(PHP_EOL, $output); // ffprobe installed if (!preg_match('/FFprobe version/i', $output)) { throw new \RuntimeException('FFprobe is not installed on host server', self::$EX_CODE_NO_FFPROBE); } // Storing persistent opening if (true === $this->persistent) { self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output; } return $output; }
php
public function getOutput() { // Persistent opening if (true === $this->persistent && array_key_exists(get_class($this).$this->binary.$this->movieFile, self::$persistentBuffer) ) { return self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile]; } // File doesn't exist if (!file_exists($this->movieFile)) { throw new \UnexpectedValueException('Movie file not found', self::$EX_CODE_FILE_NOT_FOUND); } // Get information about file from ffprobe $output = []; exec($this->binary.' '.escapeshellarg($this->movieFile).' 2>&1', $output, $retVar); $output = implode(PHP_EOL, $output); // ffprobe installed if (!preg_match('/FFprobe version/i', $output)) { throw new \RuntimeException('FFprobe is not installed on host server', self::$EX_CODE_NO_FFPROBE); } // Storing persistent opening if (true === $this->persistent) { self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output; } return $output; }
[ "public", "function", "getOutput", "(", ")", "{", "// Persistent opening", "if", "(", "true", "===", "$", "this", "->", "persistent", "&&", "array_key_exists", "(", "get_class", "(", "$", "this", ")", ".", "$", "this", "->", "binary", ".", "$", "this", "...
Getting parsable output from ffprobe binary. @return string
[ "Getting", "parsable", "output", "from", "ffprobe", "binary", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/OutputProviders/FFProbeProvider.php#L27-L58
char0n/ffmpeg-php
src/Movie.php
Movie.setProvider
public function setProvider(OutputProvider $outputProvider) { $this->provider = $outputProvider; $this->provider->setMovieFile($this->movieFile); $this->output = $this->provider->getOutput(); return $this; }
php
public function setProvider(OutputProvider $outputProvider) { $this->provider = $outputProvider; $this->provider->setMovieFile($this->movieFile); $this->output = $this->provider->getOutput(); return $this; }
[ "public", "function", "setProvider", "(", "OutputProvider", "$", "outputProvider", ")", "{", "$", "this", "->", "provider", "=", "$", "outputProvider", ";", "$", "this", "->", "provider", "->", "setMovieFile", "(", "$", "this", "->", "movieFile", ")", ";", ...
Setting output provider implementation. @param OutputProvider $outputProvider @return $this
[ "Setting", "output", "provider", "implementation", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L260-L267
char0n/ffmpeg-php
src/Movie.php
Movie.getDuration
public function getDuration() { if ($this->duration === null) { $match = []; preg_match(self::$REGEX_DURATION, $this->output, $match); if (array_key_exists(1, $match) && array_key_exists(2, $match) && array_key_exists(3, $match)) { $hours = (int)$match[1]; $minutes = (int)$match[2]; $seconds = (int)$match[3]; $fractions = (float)(array_key_exists(5, $match) ? '0.'.$match[5] : 0.0); $this->duration = (($hours * 3600) + ($minutes * 60) + $seconds + $fractions); } else { $this->duration = 0.0; } return $this->duration; } return $this->duration; }
php
public function getDuration() { if ($this->duration === null) { $match = []; preg_match(self::$REGEX_DURATION, $this->output, $match); if (array_key_exists(1, $match) && array_key_exists(2, $match) && array_key_exists(3, $match)) { $hours = (int)$match[1]; $minutes = (int)$match[2]; $seconds = (int)$match[3]; $fractions = (float)(array_key_exists(5, $match) ? '0.'.$match[5] : 0.0); $this->duration = (($hours * 3600) + ($minutes * 60) + $seconds + $fractions); } else { $this->duration = 0.0; } return $this->duration; } return $this->duration; }
[ "public", "function", "getDuration", "(", ")", "{", "if", "(", "$", "this", "->", "duration", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_DURATION", ",", "$", "this", "->", "output", ",", ...
Return the duration of a movie or audio file in seconds. @return float Movie duration in seconds.
[ "Return", "the", "duration", "of", "a", "movie", "or", "audio", "file", "in", "seconds", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L284-L304
char0n/ffmpeg-php
src/Movie.php
Movie.getFrameCount
public function getFrameCount() { if ($this->frameCount === null) { $this->frameCount = (int)($this->getDuration() * $this->getFrameRate()); } return $this->frameCount; }
php
public function getFrameCount() { if ($this->frameCount === null) { $this->frameCount = (int)($this->getDuration() * $this->getFrameRate()); } return $this->frameCount; }
[ "public", "function", "getFrameCount", "(", ")", "{", "if", "(", "$", "this", "->", "frameCount", "===", "null", ")", "{", "$", "this", "->", "frameCount", "=", "(", "int", ")", "(", "$", "this", "->", "getDuration", "(", ")", "*", "$", "this", "->...
Return the number of frames in a movie or audio file. @return int
[ "Return", "the", "number", "of", "frames", "in", "a", "movie", "or", "audio", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L311-L318
char0n/ffmpeg-php
src/Movie.php
Movie.getFrameRate
public function getFrameRate() { if ($this->frameRate === null) { $match = []; preg_match(self::$REGEX_FRAME_RATE, $this->output, $match); $this->frameRate = (float)(array_key_exists(1, $match) ? $match[1] : 0.0); } return $this->frameRate; }
php
public function getFrameRate() { if ($this->frameRate === null) { $match = []; preg_match(self::$REGEX_FRAME_RATE, $this->output, $match); $this->frameRate = (float)(array_key_exists(1, $match) ? $match[1] : 0.0); } return $this->frameRate; }
[ "public", "function", "getFrameRate", "(", ")", "{", "if", "(", "$", "this", "->", "frameRate", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_FRAME_RATE", ",", "$", "this", "->", "output", ","...
Return the frame rate of a movie in fps. @return float
[ "Return", "the", "frame", "rate", "of", "a", "movie", "in", "fps", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L325-L334
char0n/ffmpeg-php
src/Movie.php
Movie.getComment
public function getComment() { if ($this->comment === null) { $match = []; preg_match(self::$REGEX_COMMENT, $this->output, $match); $this->comment = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->comment; }
php
public function getComment() { if ($this->comment === null) { $match = []; preg_match(self::$REGEX_COMMENT, $this->output, $match); $this->comment = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->comment; }
[ "public", "function", "getComment", "(", ")", "{", "if", "(", "$", "this", "->", "comment", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_COMMENT", ",", "$", "this", "->", "output", ",", "$"...
Return the comment field from the movie or audio file. @return string
[ "Return", "the", "comment", "field", "from", "the", "movie", "or", "audio", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L351-L360
char0n/ffmpeg-php
src/Movie.php
Movie.getTitle
public function getTitle() { if ($this->title === null) { $match = []; preg_match(self::$REGEX_TITLE, $this->output, $match); $this->title = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->title; }
php
public function getTitle() { if ($this->title === null) { $match = []; preg_match(self::$REGEX_TITLE, $this->output, $match); $this->title = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->title; }
[ "public", "function", "getTitle", "(", ")", "{", "if", "(", "$", "this", "->", "title", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_TITLE", ",", "$", "this", "->", "output", ",", "$", "m...
Return the title field from the movie or audio file. @return string
[ "Return", "the", "title", "field", "from", "the", "movie", "or", "audio", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L367-L376
char0n/ffmpeg-php
src/Movie.php
Movie.getArtist
public function getArtist() { if ($this->artist === null) { $match = []; preg_match(self::$REGEX_ARTIST, $this->output, $match); $this->artist = array_key_exists(3, $match) ? trim($match[3]) : ''; } return $this->artist; }
php
public function getArtist() { if ($this->artist === null) { $match = []; preg_match(self::$REGEX_ARTIST, $this->output, $match); $this->artist = array_key_exists(3, $match) ? trim($match[3]) : ''; } return $this->artist; }
[ "public", "function", "getArtist", "(", ")", "{", "if", "(", "$", "this", "->", "artist", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_ARTIST", ",", "$", "this", "->", "output", ",", "$", ...
Return the author field from the movie or the artist ID3 field from an mp3 file; alias $movie->getArtist() @return string
[ "Return", "the", "author", "field", "from", "the", "movie", "or", "the", "artist", "ID3", "field", "from", "an", "mp3", "file", ";", "alias", "$movie", "-", ">", "getArtist", "()" ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L383-L392
char0n/ffmpeg-php
src/Movie.php
Movie.getCopyright
public function getCopyright() { if ($this->copyright === null) { $match = []; preg_match(self::$REGEX_COPYRIGHT, $this->output, $match); $this->copyright = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->copyright; }
php
public function getCopyright() { if ($this->copyright === null) { $match = []; preg_match(self::$REGEX_COPYRIGHT, $this->output, $match); $this->copyright = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->copyright; }
[ "public", "function", "getCopyright", "(", ")", "{", "if", "(", "$", "this", "->", "copyright", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_COPYRIGHT", ",", "$", "this", "->", "output", ",",...
Return the copyright field from the movie or audio file. @return string
[ "Return", "the", "copyright", "field", "from", "the", "movie", "or", "audio", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L409-L418
char0n/ffmpeg-php
src/Movie.php
Movie.getGenre
public function getGenre() { if ($this->genre === null) { $match = []; preg_match(self::$REGEX_GENRE, $this->output, $match); $this->genre = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->genre; }
php
public function getGenre() { if ($this->genre === null) { $match = []; preg_match(self::$REGEX_GENRE, $this->output, $match); $this->genre = array_key_exists(2, $match) ? trim($match[2]) : ''; } return $this->genre; }
[ "public", "function", "getGenre", "(", ")", "{", "if", "(", "$", "this", "->", "genre", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_GENRE", ",", "$", "this", "->", "output", ",", "$", "m...
Return the genre ID3 field from an mp3 file. @return string
[ "Return", "the", "genre", "ID3", "field", "from", "an", "mp3", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L425-L434
char0n/ffmpeg-php
src/Movie.php
Movie.getTrackNumber
public function getTrackNumber() { if ($this->trackNumber === null) { $match = []; preg_match(self::$REGEX_TRACK_NUMBER, $this->output, $match); $this->trackNumber = (int)(array_key_exists(2, $match) ? $match[2] : 0); } return $this->trackNumber; }
php
public function getTrackNumber() { if ($this->trackNumber === null) { $match = []; preg_match(self::$REGEX_TRACK_NUMBER, $this->output, $match); $this->trackNumber = (int)(array_key_exists(2, $match) ? $match[2] : 0); } return $this->trackNumber; }
[ "public", "function", "getTrackNumber", "(", ")", "{", "if", "(", "$", "this", "->", "trackNumber", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_TRACK_NUMBER", ",", "$", "this", "->", "output",...
Return the track ID3 field from an mp3 file. @return int
[ "Return", "the", "track", "ID3", "field", "from", "an", "mp3", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L441-L450
char0n/ffmpeg-php
src/Movie.php
Movie.getYear
public function getYear() { if ($this->year === null) { $match = []; preg_match(self::$REGEX_YEAR, $this->output, $match); $this->year = (int)(array_key_exists(2, $match) ? $match[2] : 0); } return $this->year; }
php
public function getYear() { if ($this->year === null) { $match = []; preg_match(self::$REGEX_YEAR, $this->output, $match); $this->year = (int)(array_key_exists(2, $match) ? $match[2] : 0); } return $this->year; }
[ "public", "function", "getYear", "(", ")", "{", "if", "(", "$", "this", "->", "year", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_YEAR", ",", "$", "this", "->", "output", ",", "$", "matc...
Return the year ID3 field from an mp3 file. @return int
[ "Return", "the", "year", "ID3", "field", "from", "an", "mp3", "file", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L457-L466
char0n/ffmpeg-php
src/Movie.php
Movie.getFrameHeight
public function getFrameHeight() { if (null === $this->frameHeight) { $match = []; preg_match(self::$REGEX_FRAME_WH, $this->output, $match); if (array_key_exists(1, $match) && array_key_exists(2, $match)) { $this->frameWidth = (int)$match[1]; $this->frameHeight = (int)$match[2]; } else { $this->frameWidth = 0; $this->frameHeight = 0; } } return $this->frameHeight; }
php
public function getFrameHeight() { if (null === $this->frameHeight) { $match = []; preg_match(self::$REGEX_FRAME_WH, $this->output, $match); if (array_key_exists(1, $match) && array_key_exists(2, $match)) { $this->frameWidth = (int)$match[1]; $this->frameHeight = (int)$match[2]; } else { $this->frameWidth = 0; $this->frameHeight = 0; } } return $this->frameHeight; }
[ "public", "function", "getFrameHeight", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "frameHeight", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_FRAME_WH", ",", "$", "this", "->", "output", "...
Return the height of the movie in pixels. @return int
[ "Return", "the", "height", "of", "the", "movie", "in", "pixels", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L473-L488
char0n/ffmpeg-php
src/Movie.php
Movie.getPixelFormat
public function getPixelFormat() { if ($this->pixelFormat === null) { $match = []; preg_match(self::$REGEX_PIXEL_FORMAT, $this->output, $match); $this->pixelFormat = array_key_exists(1, $match) ? trim($match[1]) : ''; } return $this->pixelFormat; }
php
public function getPixelFormat() { if ($this->pixelFormat === null) { $match = []; preg_match(self::$REGEX_PIXEL_FORMAT, $this->output, $match); $this->pixelFormat = array_key_exists(1, $match) ? trim($match[1]) : ''; } return $this->pixelFormat; }
[ "public", "function", "getPixelFormat", "(", ")", "{", "if", "(", "$", "this", "->", "pixelFormat", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_PIXEL_FORMAT", ",", "$", "this", "->", "output",...
Return the pixel format of the movie. @return string
[ "Return", "the", "pixel", "format", "of", "the", "movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L509-L518
char0n/ffmpeg-php
src/Movie.php
Movie.getPixelAspectRatio
public function getPixelAspectRatio() { if ($this->pixelAspectRatio === null) { $match = []; preg_match(self::$REGEX_PIXEL_ASPECT_RATIO, $this->output, $match); $this->pixelAspectRatio = (array_key_exists(1, $match) && array_key_exists( 2, $match )) ? ($match[1] / $match[2]) : 0; } return $this->pixelAspectRatio; }
php
public function getPixelAspectRatio() { if ($this->pixelAspectRatio === null) { $match = []; preg_match(self::$REGEX_PIXEL_ASPECT_RATIO, $this->output, $match); $this->pixelAspectRatio = (array_key_exists(1, $match) && array_key_exists( 2, $match )) ? ($match[1] / $match[2]) : 0; } return $this->pixelAspectRatio; }
[ "public", "function", "getPixelAspectRatio", "(", ")", "{", "if", "(", "$", "this", "->", "pixelAspectRatio", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_PIXEL_ASPECT_RATIO", ",", "$", "this", "...
Return the pixel aspect ratio of the movie. @return float
[ "Return", "the", "pixel", "aspect", "ratio", "of", "the", "movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L525-L537
char0n/ffmpeg-php
src/Movie.php
Movie.getRotation
public function getRotation() { if ($this->rotation === null) { $match = array(); preg_match(self::$REGEX_ROTATION, $this->output, $match); $this->rotation = (array_key_exists(1, $match)) ? intval(trim($match[1])) : 0; } return $this->rotation; }
php
public function getRotation() { if ($this->rotation === null) { $match = array(); preg_match(self::$REGEX_ROTATION, $this->output, $match); $this->rotation = (array_key_exists(1, $match)) ? intval(trim($match[1])) : 0; } return $this->rotation; }
[ "public", "function", "getRotation", "(", ")", "{", "if", "(", "$", "this", "->", "rotation", "===", "null", ")", "{", "$", "match", "=", "array", "(", ")", ";", "preg_match", "(", "self", "::", "$", "REGEX_ROTATION", ",", "$", "this", "->", "output"...
Return the rotation angle of the movie. @return int
[ "Return", "the", "rotation", "angle", "of", "the", "movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L544-L552
char0n/ffmpeg-php
src/Movie.php
Movie.getBitRate
public function getBitRate() { if ($this->bitRate === null) { $match = []; preg_match(self::$REGEX_BITRATE, $this->output, $match); $this->bitRate = (int)(array_key_exists(1, $match) ? ($match[1] * 1000) : 0); } return $this->bitRate; }
php
public function getBitRate() { if ($this->bitRate === null) { $match = []; preg_match(self::$REGEX_BITRATE, $this->output, $match); $this->bitRate = (int)(array_key_exists(1, $match) ? ($match[1] * 1000) : 0); } return $this->bitRate; }
[ "public", "function", "getBitRate", "(", ")", "{", "if", "(", "$", "this", "->", "bitRate", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_BITRATE", ",", "$", "this", "->", "output", ",", "$"...
Return the bit rate of the movie or audio file in bits per second. @return int
[ "Return", "the", "bit", "rate", "of", "the", "movie", "or", "audio", "file", "in", "bits", "per", "second", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L559-L568
char0n/ffmpeg-php
src/Movie.php
Movie.getVideoBitRate
public function getVideoBitRate() { if ($this->videoBitRate === null) { $match = []; preg_match(self::$REGEX_VIDEO_BITRATE, $this->output, $match); $this->videoBitRate = (int)(array_key_exists(1, $match) ? ($match[1] * 1000) : 0); } return $this->videoBitRate; }
php
public function getVideoBitRate() { if ($this->videoBitRate === null) { $match = []; preg_match(self::$REGEX_VIDEO_BITRATE, $this->output, $match); $this->videoBitRate = (int)(array_key_exists(1, $match) ? ($match[1] * 1000) : 0); } return $this->videoBitRate; }
[ "public", "function", "getVideoBitRate", "(", ")", "{", "if", "(", "$", "this", "->", "videoBitRate", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_VIDEO_BITRATE", ",", "$", "this", "->", "outpu...
Return the bit rate of the video in bits per second. NOTE: This only works for files with constant bit rate. @return int
[ "Return", "the", "bit", "rate", "of", "the", "video", "in", "bits", "per", "second", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L577-L586
char0n/ffmpeg-php
src/Movie.php
Movie.getAudioBitRate
public function getAudioBitRate() { if ($this->audioBitRate === null) { $match = []; preg_match(self::$REGEX_AUDIO_BITRATE, $this->output, $match); $this->audioBitRate = (int)(array_key_exists(1, $match) ? ($match[1] * 1000) : 0); } return $this->audioBitRate; }
php
public function getAudioBitRate() { if ($this->audioBitRate === null) { $match = []; preg_match(self::$REGEX_AUDIO_BITRATE, $this->output, $match); $this->audioBitRate = (int)(array_key_exists(1, $match) ? ($match[1] * 1000) : 0); } return $this->audioBitRate; }
[ "public", "function", "getAudioBitRate", "(", ")", "{", "if", "(", "$", "this", "->", "audioBitRate", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_AUDIO_BITRATE", ",", "$", "this", "->", "outpu...
Return the audio bit rate of the media file in bits per second. @return int
[ "Return", "the", "audio", "bit", "rate", "of", "the", "media", "file", "in", "bits", "per", "second", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L593-L602
char0n/ffmpeg-php
src/Movie.php
Movie.getAudioSampleRate
public function getAudioSampleRate() { if ($this->audioSampleRate === null) { $match = []; preg_match(self::$REGEX_AUDIO_SAMPLE_RATE, $this->output, $match); $this->audioSampleRate = (int)(array_key_exists(1, $match) ? $match[1] : 0); } return $this->audioSampleRate; }
php
public function getAudioSampleRate() { if ($this->audioSampleRate === null) { $match = []; preg_match(self::$REGEX_AUDIO_SAMPLE_RATE, $this->output, $match); $this->audioSampleRate = (int)(array_key_exists(1, $match) ? $match[1] : 0); } return $this->audioSampleRate; }
[ "public", "function", "getAudioSampleRate", "(", ")", "{", "if", "(", "$", "this", "->", "audioSampleRate", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_AUDIO_SAMPLE_RATE", ",", "$", "this", "->"...
Return the audio sample rate of the media file in bits per second. @return int
[ "Return", "the", "audio", "sample", "rate", "of", "the", "media", "file", "in", "bits", "per", "second", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L609-L618
char0n/ffmpeg-php
src/Movie.php
Movie.getVideoCodec
public function getVideoCodec() { if ($this->videoCodec === null) { $match = []; preg_match(self::$REGEX_VIDEO_CODEC, $this->output, $match); $this->videoCodec = array_key_exists(1, $match) ? trim($match[1]) : ''; } return $this->videoCodec; }
php
public function getVideoCodec() { if ($this->videoCodec === null) { $match = []; preg_match(self::$REGEX_VIDEO_CODEC, $this->output, $match); $this->videoCodec = array_key_exists(1, $match) ? trim($match[1]) : ''; } return $this->videoCodec; }
[ "public", "function", "getVideoCodec", "(", ")", "{", "if", "(", "$", "this", "->", "videoCodec", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_VIDEO_CODEC", ",", "$", "this", "->", "output", ...
Return the name of the video codec used to encode this movie. @return string
[ "Return", "the", "name", "of", "the", "video", "codec", "used", "to", "encode", "this", "movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L635-L644
char0n/ffmpeg-php
src/Movie.php
Movie.getAudioCodec
public function getAudioCodec() { if ($this->audioCodec === null) { $match = []; preg_match(self::$REGEX_AUDIO_CODEC, $this->output, $match); $this->audioCodec = array_key_exists(1, $match) ? trim($match[1]) : ''; } return $this->audioCodec; }
php
public function getAudioCodec() { if ($this->audioCodec === null) { $match = []; preg_match(self::$REGEX_AUDIO_CODEC, $this->output, $match); $this->audioCodec = array_key_exists(1, $match) ? trim($match[1]) : ''; } return $this->audioCodec; }
[ "public", "function", "getAudioCodec", "(", ")", "{", "if", "(", "$", "this", "->", "audioCodec", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_AUDIO_CODEC", ",", "$", "this", "->", "output", ...
Return the name of the audio codec used to encode this movie. @return string
[ "Return", "the", "name", "of", "the", "audio", "codec", "used", "to", "encode", "this", "movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L651-L660
char0n/ffmpeg-php
src/Movie.php
Movie.getAudioChannels
public function getAudioChannels() { if ($this->audioChannels === null) { $match = []; preg_match(self::$REGEX_AUDIO_CHANNELS, $this->output, $match); if (array_key_exists(1, $match)) { switch (trim($match[1])) { case 'mono': $this->audioChannels = 1; break; case 'stereo': $this->audioChannels = 2; break; case '5.1': $this->audioChannels = 6; break; case '5:1': $this->audioChannels = 6; break; default: $this->audioChannels = (int)$match[1]; } } else { $this->audioChannels = 0; } } return $this->audioChannels; }
php
public function getAudioChannels() { if ($this->audioChannels === null) { $match = []; preg_match(self::$REGEX_AUDIO_CHANNELS, $this->output, $match); if (array_key_exists(1, $match)) { switch (trim($match[1])) { case 'mono': $this->audioChannels = 1; break; case 'stereo': $this->audioChannels = 2; break; case '5.1': $this->audioChannels = 6; break; case '5:1': $this->audioChannels = 6; break; default: $this->audioChannels = (int)$match[1]; } } else { $this->audioChannels = 0; } } return $this->audioChannels; }
[ "public", "function", "getAudioChannels", "(", ")", "{", "if", "(", "$", "this", "->", "audioChannels", "===", "null", ")", "{", "$", "match", "=", "[", "]", ";", "preg_match", "(", "self", "::", "$", "REGEX_AUDIO_CHANNELS", ",", "$", "this", "->", "ou...
Return the number of audio channels in this movie. @return int
[ "Return", "the", "number", "of", "audio", "channels", "in", "this", "movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L667-L695
char0n/ffmpeg-php
src/Movie.php
Movie.getFrame
public function getFrame($frameNumber = null, $width = null, $height = null, $quality = null) { $framePos = ($frameNumber === null) ? $this->frameNumber : (((int)$frameNumber) - 1); // Frame position out of range if (!is_numeric($framePos) || $framePos < 0 || $framePos > $this->getFrameCount()) { return false; } $frameTime = round(($framePos / $this->getFrameCount()) * $this->getDuration(), 4); $frame = $this->getFrameAtTime($frameTime, $width, $height, $quality); // Increment internal frame number if ($frameNumber === null) { ++$this->frameNumber; } return $frame; }
php
public function getFrame($frameNumber = null, $width = null, $height = null, $quality = null) { $framePos = ($frameNumber === null) ? $this->frameNumber : (((int)$frameNumber) - 1); // Frame position out of range if (!is_numeric($framePos) || $framePos < 0 || $framePos > $this->getFrameCount()) { return false; } $frameTime = round(($framePos / $this->getFrameCount()) * $this->getDuration(), 4); $frame = $this->getFrameAtTime($frameTime, $width, $height, $quality); // Increment internal frame number if ($frameNumber === null) { ++$this->frameNumber; } return $frame; }
[ "public", "function", "getFrame", "(", "$", "frameNumber", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "quality", "=", "null", ")", "{", "$", "framePos", "=", "(", "$", "frameNumber", "===", "null", ")", ...
Returns a frame from the movie as an Frame object. Returns false if the frame was not found. @param int $frameNumber Frame from the movie to return. If no frame number is specified, returns the next frame of the movie. @param int $width @param int $height @param int $quality @return Frame|boolean
[ "Returns", "a", "frame", "from", "the", "movie", "as", "an", "Frame", "object", ".", "Returns", "false", "if", "the", "frame", "was", "not", "found", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L728-L747
char0n/ffmpeg-php
src/Movie.php
Movie.getFrameAtTime
public function getFrameAtTime( $seconds = null, $width = null, $height = null, $quality = null, $frameFilePath = null, &$output = null ) { // set frame position for frame extraction $frameTime = ($seconds === null) ? 0 : $seconds; // time out of range if (!is_numeric($frameTime) || $frameTime < 0 || $frameTime > $this->getDuration()) { throw new \RuntimeException( 'Frame time is not in range '.$frameTime.'/'.$this->getDuration().' '.$this->getFilename() ); } $image_size = ''; if (is_numeric($height) && is_numeric($width)) { $image_size = ' -s '.$width.'x'.$height; } $qualityCommand = ''; if (is_numeric($quality)) { $qualityCommand = ' -qscale '.$quality; } $deleteTmp = false; if ($frameFilePath === null) { $frameFilePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('frame', true).'.jpg'; $deleteTmp = true; } $output = []; // Fast and accurate way to seek. First quick-seek before input up to // a point just before the frame, and then accurately seek after input // to the exact point. // See: http://ffmpeg.org/trac/ffmpeg/wiki/Seeking%20with%20FFmpeg if ($frameTime > 30) { $seek1 = $frameTime - 30; $seek2 = 30; } else { $seek1 = 0; $seek2 = $frameTime; } exec( implode( ' ', [ $this->ffmpegBinary, '-ss '.$seek1, '-i '.escapeshellarg($this->movieFile), '-f image2', '-ss '.$seek2, '-vframes 1', $image_size, $qualityCommand, escapeshellarg($frameFilePath), '2>&1', ] ), $output, $retVar ); /** @noinspection ReferenceMismatchInspection */ $stringOutput = implode(PHP_EOL, $output); // Cannot write frame to the data storage if (!file_exists($frameFilePath)) { // Find error in output preg_match(self::$REGEX_ERRORS, $stringOutput, $errors); if ($errors) { throw new \RuntimeException($errors[0]); } // Default file not found error throw new \RuntimeException('TMP image not found/written '.$frameFilePath); } // Create gdimage and delete temporary image $imageSize = getimagesize($frameFilePath); switch ($imageSize[2]) { case IMAGETYPE_GIF: $gdImage = imagecreatefromgif($frameFilePath); break; case IMAGETYPE_PNG: $gdImage = imagecreatefrompng($frameFilePath); break; default: $gdImage = imagecreatefromjpeg($frameFilePath); } if ($deleteTmp && is_writable($frameFilePath)) { unlink($frameFilePath); } $frame = new Frame($gdImage, $frameTime); imagedestroy($gdImage); return $frame; }
php
public function getFrameAtTime( $seconds = null, $width = null, $height = null, $quality = null, $frameFilePath = null, &$output = null ) { // set frame position for frame extraction $frameTime = ($seconds === null) ? 0 : $seconds; // time out of range if (!is_numeric($frameTime) || $frameTime < 0 || $frameTime > $this->getDuration()) { throw new \RuntimeException( 'Frame time is not in range '.$frameTime.'/'.$this->getDuration().' '.$this->getFilename() ); } $image_size = ''; if (is_numeric($height) && is_numeric($width)) { $image_size = ' -s '.$width.'x'.$height; } $qualityCommand = ''; if (is_numeric($quality)) { $qualityCommand = ' -qscale '.$quality; } $deleteTmp = false; if ($frameFilePath === null) { $frameFilePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('frame', true).'.jpg'; $deleteTmp = true; } $output = []; // Fast and accurate way to seek. First quick-seek before input up to // a point just before the frame, and then accurately seek after input // to the exact point. // See: http://ffmpeg.org/trac/ffmpeg/wiki/Seeking%20with%20FFmpeg if ($frameTime > 30) { $seek1 = $frameTime - 30; $seek2 = 30; } else { $seek1 = 0; $seek2 = $frameTime; } exec( implode( ' ', [ $this->ffmpegBinary, '-ss '.$seek1, '-i '.escapeshellarg($this->movieFile), '-f image2', '-ss '.$seek2, '-vframes 1', $image_size, $qualityCommand, escapeshellarg($frameFilePath), '2>&1', ] ), $output, $retVar ); /** @noinspection ReferenceMismatchInspection */ $stringOutput = implode(PHP_EOL, $output); // Cannot write frame to the data storage if (!file_exists($frameFilePath)) { // Find error in output preg_match(self::$REGEX_ERRORS, $stringOutput, $errors); if ($errors) { throw new \RuntimeException($errors[0]); } // Default file not found error throw new \RuntimeException('TMP image not found/written '.$frameFilePath); } // Create gdimage and delete temporary image $imageSize = getimagesize($frameFilePath); switch ($imageSize[2]) { case IMAGETYPE_GIF: $gdImage = imagecreatefromgif($frameFilePath); break; case IMAGETYPE_PNG: $gdImage = imagecreatefrompng($frameFilePath); break; default: $gdImage = imagecreatefromjpeg($frameFilePath); } if ($deleteTmp && is_writable($frameFilePath)) { unlink($frameFilePath); } $frame = new Frame($gdImage, $frameTime); imagedestroy($gdImage); return $frame; }
[ "public", "function", "getFrameAtTime", "(", "$", "seconds", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "quality", "=", "null", ",", "$", "frameFilePath", "=", "null", ",", "&", "$", "output", "=", "null",...
Returns a frame from the movie as a Frame object. Returns false if the frame was not found. @param float $seconds @param int $width @param int $height @param int $quality @param string $frameFilePath @param array $output @throws \RuntimeException @return Frame|boolean
[ "Returns", "a", "frame", "from", "the", "movie", "as", "a", "Frame", "object", ".", "Returns", "false", "if", "the", "frame", "was", "not", "found", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L763-L866
char0n/ffmpeg-php
src/Movie.php
Movie.serialize
public function serialize() { $data = serialize( [ $this->ffmpegBinary, $this->movieFile, $this->output, $this->frameNumber, $this->provider, ] ); return $data; }
php
public function serialize() { $data = serialize( [ $this->ffmpegBinary, $this->movieFile, $this->output, $this->frameNumber, $this->provider, ] ); return $data; }
[ "public", "function", "serialize", "(", ")", "{", "$", "data", "=", "serialize", "(", "[", "$", "this", "->", "ffmpegBinary", ",", "$", "this", "->", "movieFile", ",", "$", "this", "->", "output", ",", "$", "this", "->", "frameNumber", ",", "$", "thi...
String representation of a Movie. @return string Rhe string representation of the object or null.
[ "String", "representation", "of", "a", "Movie", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L888-L901
char0n/ffmpeg-php
src/Movie.php
Movie.unserialize
public function unserialize($serialized) { list( $this->ffmpegBinary, $this->movieFile, $this->output, $this->frameNumber, $this->provider ) = unserialize($serialized); }
php
public function unserialize($serialized) { list( $this->ffmpegBinary, $this->movieFile, $this->output, $this->frameNumber, $this->provider ) = unserialize($serialized); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "list", "(", "$", "this", "->", "ffmpegBinary", ",", "$", "this", "->", "movieFile", ",", "$", "this", "->", "output", ",", "$", "this", "->", "frameNumber", ",", "$", "this", "->",...
Constructs the Movie from serialized data. @param string $serialized The string representation of Movie instance. @return void
[ "Constructs", "the", "Movie", "from", "serialized", "data", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/Movie.php#L910-L919
char0n/ffmpeg-php
src/OutputProviders/StringProvider.php
StringProvider.getOutput
public function getOutput() { // Persistent opening $bufferKey = get_class($this).$this->binary.$this->movieFile; if (true === $this->persistent && array_key_exists($bufferKey, self::$persistentBuffer) ) { return self::$persistentBuffer[$bufferKey]; } return $this->output; }
php
public function getOutput() { // Persistent opening $bufferKey = get_class($this).$this->binary.$this->movieFile; if (true === $this->persistent && array_key_exists($bufferKey, self::$persistentBuffer) ) { return self::$persistentBuffer[$bufferKey]; } return $this->output; }
[ "public", "function", "getOutput", "(", ")", "{", "// Persistent opening", "$", "bufferKey", "=", "get_class", "(", "$", "this", ")", ".", "$", "this", "->", "binary", ".", "$", "this", "->", "movieFile", ";", "if", "(", "true", "===", "$", "this", "->...
Getting parsable output from ffmpeg binary. @return string
[ "Getting", "parsable", "output", "from", "ffmpeg", "binary", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/OutputProviders/StringProvider.php#L29-L41
char0n/ffmpeg-php
src/OutputProviders/StringProvider.php
StringProvider.setOutput
public function setOutput($output) { $this->output = $output; // Storing persistent opening if (true === $this->persistent) { self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output; } }
php
public function setOutput($output) { $this->output = $output; // Storing persistent opening if (true === $this->persistent) { self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output; } }
[ "public", "function", "setOutput", "(", "$", "output", ")", "{", "$", "this", "->", "output", "=", "$", "output", ";", "// Storing persistent opening", "if", "(", "true", "===", "$", "this", "->", "persistent", ")", "{", "self", "::", "$", "persistentBuffe...
Setting parsable output. @param string $output
[ "Setting", "parsable", "output", "." ]
train
https://github.com/char0n/ffmpeg-php/blob/51cec215dc49a9c9339d6a64473be8681988373a/src/OutputProviders/StringProvider.php#L48-L56
sroze/companienv
src/Companienv/Extension/FileToPropagate.php
FileToPropagate.getVariableValue
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { if (null === ($attribute = $block->getAttribute('file-to-propagate', $variable))) { return null; } $definedVariablesHash = $companion->getDefinedVariablesHash(); $fileSystem = $companion->getFileSystem(); // If the file exists and seems legit, keep the file. if ($fileSystem->exists($filename = $variable->getValue()) && isset($definedVariablesHash[$variable->getName()])) { return $definedVariablesHash[$variable->getName()]; } $downloadedFilePath = $companion->ask('<comment>'.$variable->getName().'</comment>: What is the path of your downloaded file? '); if (!$fileSystem->exists($downloadedFilePath, false)) { throw new \InvalidArgumentException(sprintf('The file "%s" does not exist', $downloadedFilePath)); } if (false === $fileSystem->write($filename, $fileSystem->getContents($downloadedFilePath, false))) { throw new \RuntimeException(sprintf( 'Unable to write into "%s"', $filename )); } return $variable->getValue(); }
php
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { if (null === ($attribute = $block->getAttribute('file-to-propagate', $variable))) { return null; } $definedVariablesHash = $companion->getDefinedVariablesHash(); $fileSystem = $companion->getFileSystem(); // If the file exists and seems legit, keep the file. if ($fileSystem->exists($filename = $variable->getValue()) && isset($definedVariablesHash[$variable->getName()])) { return $definedVariablesHash[$variable->getName()]; } $downloadedFilePath = $companion->ask('<comment>'.$variable->getName().'</comment>: What is the path of your downloaded file? '); if (!$fileSystem->exists($downloadedFilePath, false)) { throw new \InvalidArgumentException(sprintf('The file "%s" does not exist', $downloadedFilePath)); } if (false === $fileSystem->write($filename, $fileSystem->getContents($downloadedFilePath, false))) { throw new \RuntimeException(sprintf( 'Unable to write into "%s"', $filename )); } return $variable->getValue(); }
[ "public", "function", "getVariableValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ")", "{", "if", "(", "null", "===", "(", "$", "attribute", "=", "$", "block", "->", "getAttribute", "(", "'file-to-p...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/FileToPropagate.php#L15-L42
sroze/companienv
src/Companienv/Extension/FileToPropagate.php
FileToPropagate.isVariableRequiringValue
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { if (null === ($attribute = $block->getAttribute('file-to-propagate', $variable))) { return Extension::ABSTAIN; } return $companion->getFileSystem()->exists($variable->getValue()) ? Extension::VARIABLE_REQUIRED : Extension::ABSTAIN; }
php
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { if (null === ($attribute = $block->getAttribute('file-to-propagate', $variable))) { return Extension::ABSTAIN; } return $companion->getFileSystem()->exists($variable->getValue()) ? Extension::VARIABLE_REQUIRED : Extension::ABSTAIN; }
[ "public", "function", "isVariableRequiringValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ",", "string", "$", "currentValue", "=", "null", ")", ":", "int", "{", "if", "(", "null", "===", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/FileToPropagate.php#L47-L56
sroze/companienv
src/Companienv/Interaction/AskVariableValues.php
AskVariableValues.getVariableValue
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { $definedVariablesHash = $companion->getDefinedVariablesHash(); $defaultValue = ($definedVariablesHash[$variable->getName()] ?? $variable->getValue()) ?: $variable->getValue(); $question = sprintf('<comment>%s</comment> ? ', $variable->getName()); if ($defaultValue !== '') { $question .= '('.$defaultValue.') '; } return $companion->ask($question, $defaultValue); }
php
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { $definedVariablesHash = $companion->getDefinedVariablesHash(); $defaultValue = ($definedVariablesHash[$variable->getName()] ?? $variable->getValue()) ?: $variable->getValue(); $question = sprintf('<comment>%s</comment> ? ', $variable->getName()); if ($defaultValue !== '') { $question .= '('.$defaultValue.') '; } return $companion->ask($question, $defaultValue); }
[ "public", "function", "getVariableValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ")", "{", "$", "definedVariablesHash", "=", "$", "companion", "->", "getDefinedVariablesHash", "(", ")", ";", "$", "defa...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Interaction/AskVariableValues.php#L15-L26
sroze/companienv
src/Companienv/Interaction/AskVariableValues.php
AskVariableValues.isVariableRequiringValue
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { return ( $currentValue === null || ( $currentValue === '' && $variable->getValue() !== '' ) ) ? Extension::VARIABLE_REQUIRED : Extension::ABSTAIN; }
php
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { return ( $currentValue === null || ( $currentValue === '' && $variable->getValue() !== '' ) ) ? Extension::VARIABLE_REQUIRED : Extension::ABSTAIN; }
[ "public", "function", "isVariableRequiringValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ",", "string", "$", "currentValue", "=", "null", ")", ":", "int", "{", "return", "(", "$", "currentValue", "==...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Interaction/AskVariableValues.php#L31-L38
sroze/companienv
src/Companienv/DotEnv/Block.php
Block.getVariablesInBlock
public function getVariablesInBlock(array $variables) { $blockVariableNames = array_map(function (Variable $variable) { return $variable->getName(); }, $this->variables); return array_filter($variables, function (Variable $variable) use ($blockVariableNames) { return in_array($variable->getName(), $blockVariableNames); }); }
php
public function getVariablesInBlock(array $variables) { $blockVariableNames = array_map(function (Variable $variable) { return $variable->getName(); }, $this->variables); return array_filter($variables, function (Variable $variable) use ($blockVariableNames) { return in_array($variable->getName(), $blockVariableNames); }); }
[ "public", "function", "getVariablesInBlock", "(", "array", "$", "variables", ")", "{", "$", "blockVariableNames", "=", "array_map", "(", "function", "(", "Variable", "$", "variable", ")", "{", "return", "$", "variable", "->", "getName", "(", ")", ";", "}", ...
Return only the variables that are in the block. @param Variable[] $variables @return Variable[]
[ "Return", "only", "the", "variables", "that", "are", "in", "the", "block", "." ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/DotEnv/Block.php#L72-L81
sroze/companienv
src/Companienv/DotEnv/Block.php
Block.getVariable
public function getVariable(string $name) { foreach ($this->variables as $variable) { if ($variable->getName() == $name) { return $variable; } } return null; }
php
public function getVariable(string $name) { foreach ($this->variables as $variable) { if ($variable->getName() == $name) { return $variable; } } return null; }
[ "public", "function", "getVariable", "(", "string", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "variables", "as", "$", "variable", ")", "{", "if", "(", "$", "variable", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "return", ...
@param string $name @return Variable|null
[ "@param", "string", "$name" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/DotEnv/Block.php#L88-L97
sroze/companienv
src/Companienv/DotEnv/Block.php
Block.getAttribute
public function getAttribute(string $name, Variable $forVariable = null) { foreach ($this->attributes as $attribute) { if ( $attribute->getName() == $name && ( $forVariable === null || in_array($forVariable->getName(), $attribute->getVariableNames()) ) ) { return $attribute; } } return null; }
php
public function getAttribute(string $name, Variable $forVariable = null) { foreach ($this->attributes as $attribute) { if ( $attribute->getName() == $name && ( $forVariable === null || in_array($forVariable->getName(), $attribute->getVariableNames()) ) ) { return $attribute; } } return null; }
[ "public", "function", "getAttribute", "(", "string", "$", "name", ",", "Variable", "$", "forVariable", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attribute", ")", "{", "if", "(", "$", "attribute", "->", "getName",...
@param string $name @param Variable|null $forVariable Will return only attribute for the given variables @return Attribute|null
[ "@param", "string", "$name", "@param", "Variable|null", "$forVariable", "Will", "return", "only", "attribute", "for", "the", "given", "variables" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/DotEnv/Block.php#L105-L120
sroze/companienv
src/Companienv/Extension/AbstractExtension.php
AbstractExtension.isVariableRequiringValue
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { return Extension::ABSTAIN; }
php
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { return Extension::ABSTAIN; }
[ "public", "function", "isVariableRequiringValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ",", "string", "$", "currentValue", "=", "null", ")", ":", "int", "{", "return", "Extension", "::", "ABSTAIN", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/AbstractExtension.php#L27-L30
sroze/companienv
src/Companienv/Extension/OnlyIf.php
OnlyIf.getVariableValue
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { if (null === ($attribute = $block->getAttribute('only-if', $variable))) { return null; } if (!$this->matchesCondition($companion, $attribute)) { return $variable->getValue(); } }
php
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { if (null === ($attribute = $block->getAttribute('only-if', $variable))) { return null; } if (!$this->matchesCondition($companion, $attribute)) { return $variable->getValue(); } }
[ "public", "function", "getVariableValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ")", "{", "if", "(", "null", "===", "(", "$", "attribute", "=", "$", "block", "->", "getAttribute", "(", "'only-if'"...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/OnlyIf.php#L16-L25
sroze/companienv
src/Companienv/Extension/OnlyIf.php
OnlyIf.isVariableRequiringValue
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { if (null === ($attribute = $block->getAttribute('only-if', $variable))) { return Extension::ABSTAIN; } return $this->matchesCondition($companion, $attribute) ? Extension::ABSTAIN : Extension::VARIABLE_SKIP; }
php
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { if (null === ($attribute = $block->getAttribute('only-if', $variable))) { return Extension::ABSTAIN; } return $this->matchesCondition($companion, $attribute) ? Extension::ABSTAIN : Extension::VARIABLE_SKIP; }
[ "public", "function", "isVariableRequiringValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ",", "string", "$", "currentValue", "=", "null", ")", ":", "int", "{", "if", "(", "null", "===", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/OnlyIf.php#L30-L39
sroze/companienv
src/Companienv/Extension/RsaKeys.php
RsaKeys.getVariableValue
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { if (null === ($attribute = $block->getAttribute('rsa-pair', $variable))) { return null; } if (isset($this->populatedVariables[$variable->getName()])) { return $this->populatedVariables[$variable->getName()]; } if (!$companion->askConfirmation(sprintf( 'Variables %s represents an RSA public/private key. Do you want to automatically generate them? (y) ', implode(' and ', array_map(function ($variable) { return '<comment>'.$variable.'</comment>'; }, $attribute->getVariableNames())) ))) { // Ensure we don't ask anymore for this variable pair foreach ($attribute->getVariableNames() as $variable) { $this->populatedVariables[$variable] = null; } return null; } $fileSystem = $companion->getFileSystem(); $passPhrase = $companion->ask('Enter pass phrase to protect the keys: '); $privateKeyPath = $block->getVariable($privateKeyVariableName = $attribute->getVariableNames()[0])->getValue(); $publicKeyPath = $block->getVariable($publicKeyVariableName = $attribute->getVariableNames()[1])->getValue(); try { (new Process(sprintf('openssl genrsa -out %s -aes256 -passout pass:%s 4096', $fileSystem->realpath($privateKeyPath), $passPhrase)))->mustRun(); (new Process(sprintf('openssl rsa -pubout -in %s -out %s -passin pass:%s', $fileSystem->realpath($privateKeyPath), $fileSystem->realpath($publicKeyPath), $passPhrase)))->mustRun(); } catch (\Symfony\Component\Process\Exception\RuntimeException $e) { throw new \RuntimeException('Could not have generated the RSA public/private key', $e->getCode(), $e); } $this->populatedVariables[$privateKeyVariableName] = $privateKeyPath; $this->populatedVariables[$publicKeyVariableName] = $publicKeyPath; $this->populatedVariables[$attribute->getVariableNames()[2]] = $passPhrase; return $this->populatedVariables[$variable->getName()]; }
php
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { if (null === ($attribute = $block->getAttribute('rsa-pair', $variable))) { return null; } if (isset($this->populatedVariables[$variable->getName()])) { return $this->populatedVariables[$variable->getName()]; } if (!$companion->askConfirmation(sprintf( 'Variables %s represents an RSA public/private key. Do you want to automatically generate them? (y) ', implode(' and ', array_map(function ($variable) { return '<comment>'.$variable.'</comment>'; }, $attribute->getVariableNames())) ))) { // Ensure we don't ask anymore for this variable pair foreach ($attribute->getVariableNames() as $variable) { $this->populatedVariables[$variable] = null; } return null; } $fileSystem = $companion->getFileSystem(); $passPhrase = $companion->ask('Enter pass phrase to protect the keys: '); $privateKeyPath = $block->getVariable($privateKeyVariableName = $attribute->getVariableNames()[0])->getValue(); $publicKeyPath = $block->getVariable($publicKeyVariableName = $attribute->getVariableNames()[1])->getValue(); try { (new Process(sprintf('openssl genrsa -out %s -aes256 -passout pass:%s 4096', $fileSystem->realpath($privateKeyPath), $passPhrase)))->mustRun(); (new Process(sprintf('openssl rsa -pubout -in %s -out %s -passin pass:%s', $fileSystem->realpath($privateKeyPath), $fileSystem->realpath($publicKeyPath), $passPhrase)))->mustRun(); } catch (\Symfony\Component\Process\Exception\RuntimeException $e) { throw new \RuntimeException('Could not have generated the RSA public/private key', $e->getCode(), $e); } $this->populatedVariables[$privateKeyVariableName] = $privateKeyPath; $this->populatedVariables[$publicKeyVariableName] = $publicKeyPath; $this->populatedVariables[$attribute->getVariableNames()[2]] = $passPhrase; return $this->populatedVariables[$variable->getName()]; }
[ "public", "function", "getVariableValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ")", "{", "if", "(", "null", "===", "(", "$", "attribute", "=", "$", "block", "->", "getAttribute", "(", "'rsa-pair'...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/RsaKeys.php#L18-L59
sroze/companienv
src/Companienv/Extension/RsaKeys.php
RsaKeys.isVariableRequiringValue
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { if (null === ($attribute = $block->getAttribute('rsa-pair', $variable))) { return Extension::ABSTAIN; } $fileSystem = $companion->getFileSystem(); return ( !$fileSystem->exists($block->getVariable($attribute->getVariableNames()[0])->getValue()) || !$fileSystem->exists($block->getVariable($attribute->getVariableNames()[1])->getValue()) ) ? Extension::VARIABLE_REQUIRED : Extension::ABSTAIN; }
php
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { if (null === ($attribute = $block->getAttribute('rsa-pair', $variable))) { return Extension::ABSTAIN; } $fileSystem = $companion->getFileSystem(); return ( !$fileSystem->exists($block->getVariable($attribute->getVariableNames()[0])->getValue()) || !$fileSystem->exists($block->getVariable($attribute->getVariableNames()[1])->getValue()) ) ? Extension::VARIABLE_REQUIRED : Extension::ABSTAIN; }
[ "public", "function", "isVariableRequiringValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ",", "string", "$", "currentValue", "=", "null", ")", ":", "int", "{", "if", "(", "null", "===", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/RsaKeys.php#L64-L77
sroze/companienv
src/Companienv/Extension/Chained.php
Chained.getVariableValue
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { foreach ($this->extensions as $extension) { if (null !== ($value = $extension->getVariableValue($companion, $block, $variable))) { return $value; } } return null; }
php
public function getVariableValue(Companion $companion, Block $block, Variable $variable) { foreach ($this->extensions as $extension) { if (null !== ($value = $extension->getVariableValue($companion, $block, $variable))) { return $value; } } return null; }
[ "public", "function", "getVariableValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ")", "{", "foreach", "(", "$", "this", "->", "extensions", "as", "$", "extension", ")", "{", "if", "(", "null", "!...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/Chained.php#L28-L37
sroze/companienv
src/Companienv/Extension/Chained.php
Chained.isVariableRequiringValue
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { foreach ($this->extensions as $extension) { if (($vote = $extension->isVariableRequiringValue($companion, $block, $variable, $currentValue)) != Extension::ABSTAIN) { return $vote; } } return Extension::ABSTAIN; }
php
public function isVariableRequiringValue(Companion $companion, Block $block, Variable $variable, string $currentValue = null) : int { foreach ($this->extensions as $extension) { if (($vote = $extension->isVariableRequiringValue($companion, $block, $variable, $currentValue)) != Extension::ABSTAIN) { return $vote; } } return Extension::ABSTAIN; }
[ "public", "function", "isVariableRequiringValue", "(", "Companion", "$", "companion", ",", "Block", "$", "block", ",", "Variable", "$", "variable", ",", "string", "$", "currentValue", "=", "null", ")", ":", "int", "{", "foreach", "(", "$", "this", "->", "e...
{@inheritdoc}
[ "{" ]
train
https://github.com/sroze/companienv/blob/bff66f395a23e843ceb9eba4f9bc5b6319461407/src/Companienv/Extension/Chained.php#L42-L51
sendpulse/sendpulse-rest-api-php
src/Storage/MemcachedStorage.php
MemcachedStorage.set
public function set($key, $token) { $this->instance->set($key, $token, $this->keyTtl); }
php
public function set($key, $token) { $this->instance->set($key, $token, $this->keyTtl); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "token", ")", "{", "$", "this", "->", "instance", "->", "set", "(", "$", "key", ",", "$", "token", ",", "$", "this", "->", "keyTtl", ")", ";", "}" ]
@param $key string @param $token @return void
[ "@param", "$key", "string", "@param", "$token" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/Storage/MemcachedStorage.php#L77-L80
sendpulse/sendpulse-rest-api-php
src/Storage/MemcachedStorage.php
MemcachedStorage.get
public function get($key) { $token = $this->instance->get($key); if (!empty($token)) { return $token; } return null; }
php
public function get($key) { $token = $this->instance->get($key); if (!empty($token)) { return $token; } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "token", "=", "$", "this", "->", "instance", "->", "get", "(", "$", "key", ")", ";", "if", "(", "!", "empty", "(", "$", "token", ")", ")", "{", "return", "$", "token", ";", "}", "re...
@param $key string @return mixed
[ "@param", "$key", "string" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/Storage/MemcachedStorage.php#L87-L95
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getToken
private function getToken() { $data = array( 'grant_type' => 'client_credentials', 'client_id' => $this->userId, 'client_secret' => $this->secret, ); $requestResult = $this->sendRequest('oauth/access_token', 'POST', $data, false); if ($requestResult->http_code !== 200) { return false; } $this->refreshToken = 0; $this->token = $requestResult->data->access_token; $hashName = md5($this->userId . '::' . $this->secret); /** Save token to storage */ $this->tokenStorage->set($hashName, $this->token); return true; }
php
private function getToken() { $data = array( 'grant_type' => 'client_credentials', 'client_id' => $this->userId, 'client_secret' => $this->secret, ); $requestResult = $this->sendRequest('oauth/access_token', 'POST', $data, false); if ($requestResult->http_code !== 200) { return false; } $this->refreshToken = 0; $this->token = $requestResult->data->access_token; $hashName = md5($this->userId . '::' . $this->secret); /** Save token to storage */ $this->tokenStorage->set($hashName, $this->token); return true; }
[ "private", "function", "getToken", "(", ")", "{", "$", "data", "=", "array", "(", "'grant_type'", "=>", "'client_credentials'", ",", "'client_id'", "=>", "$", "this", "->", "userId", ",", "'client_secret'", "=>", "$", "this", "->", "secret", ",", ")", ";",...
Get token and store it @return bool
[ "Get", "token", "and", "store", "it" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L72-L94
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.sendRequest
protected function sendRequest($path, $method = 'GET', $data = array(), $useToken = true) { $url = $this->apiUrl . '/' . $path; $method = strtoupper($method); $curl = curl_init(); if ($useToken && !empty($this->token)) { $headers = array('Authorization: Bearer ' . $this->token); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } switch ($method) { case 'POST': curl_setopt($curl, CURLOPT_POST, count($data)); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); break; case 'PUT': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); break; case 'DELETE': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); break; default: if (!empty($data)) { $url .= '?' . http_build_query($data); } } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($curl, CURLOPT_TIMEOUT, 15); $response = curl_exec($curl); $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $headerCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $responseBody = substr($response, $header_size); curl_close($curl); if ($headerCode === 401 && $this->refreshToken === 0) { ++$this->refreshToken; $this->getToken(); $retval = $this->sendRequest($path, $method, $data); } else { $retval = new stdClass(); $retval->data = json_decode($responseBody); $retval->http_code = $headerCode; } return $retval; }
php
protected function sendRequest($path, $method = 'GET', $data = array(), $useToken = true) { $url = $this->apiUrl . '/' . $path; $method = strtoupper($method); $curl = curl_init(); if ($useToken && !empty($this->token)) { $headers = array('Authorization: Bearer ' . $this->token); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } switch ($method) { case 'POST': curl_setopt($curl, CURLOPT_POST, count($data)); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); break; case 'PUT': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); break; case 'DELETE': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); break; default: if (!empty($data)) { $url .= '?' . http_build_query($data); } } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($curl, CURLOPT_TIMEOUT, 15); $response = curl_exec($curl); $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $headerCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $responseBody = substr($response, $header_size); curl_close($curl); if ($headerCode === 401 && $this->refreshToken === 0) { ++$this->refreshToken; $this->getToken(); $retval = $this->sendRequest($path, $method, $data); } else { $retval = new stdClass(); $retval->data = json_decode($responseBody); $retval->http_code = $headerCode; } return $retval; }
[ "protected", "function", "sendRequest", "(", "$", "path", ",", "$", "method", "=", "'GET'", ",", "$", "data", "=", "array", "(", ")", ",", "$", "useToken", "=", "true", ")", "{", "$", "url", "=", "$", "this", "->", "apiUrl", ".", "'/'", ".", "$",...
Form and send request to API service @param $path @param string $method @param array $data @param bool $useToken @return stdClass
[ "Form", "and", "send", "request", "to", "API", "service" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L106-L162
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.handleResult
protected function handleResult($data) { if (empty($data->data)) { $data->data = new stdClass(); } if ($data->http_code !== 200) { $data->data->is_error = true; $data->data->http_code = $data->http_code; } return $data->data; }
php
protected function handleResult($data) { if (empty($data->data)) { $data->data = new stdClass(); } if ($data->http_code !== 200) { $data->data->is_error = true; $data->data->http_code = $data->http_code; } return $data->data; }
[ "protected", "function", "handleResult", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", "->", "data", ")", ")", "{", "$", "data", "->", "data", "=", "new", "stdClass", "(", ")", ";", "}", "if", "(", "$", "data", "->", "http_cod...
Process results @param $data @return stdClass
[ "Process", "results" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L171-L182
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.handleError
protected function handleError($customMessage = null) { $message = new stdClass(); $message->is_error = true; if (null !== $customMessage) { $message->message = $customMessage; } return $message; }
php
protected function handleError($customMessage = null) { $message = new stdClass(); $message->is_error = true; if (null !== $customMessage) { $message->message = $customMessage; } return $message; }
[ "protected", "function", "handleError", "(", "$", "customMessage", "=", "null", ")", "{", "$", "message", "=", "new", "stdClass", "(", ")", ";", "$", "message", "->", "is_error", "=", "true", ";", "if", "(", "null", "!==", "$", "customMessage", ")", "{...
Process errors @param null $customMessage @return stdClass
[ "Process", "errors" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L191-L200
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.createAddressBook
public function createAddressBook($bookName) { if (empty($bookName)) { return $this->handleError('Empty book name'); } $data = array('bookName' => $bookName); $requestResult = $this->sendRequest('addressbooks', 'POST', $data); return $this->handleResult($requestResult); }
php
public function createAddressBook($bookName) { if (empty($bookName)) { return $this->handleError('Empty book name'); } $data = array('bookName' => $bookName); $requestResult = $this->sendRequest('addressbooks', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "createAddressBook", "(", "$", "bookName", ")", "{", "if", "(", "empty", "(", "$", "bookName", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book name'", ")", ";", "}", "$", "data", "=", "array", "(", "'b...
Create address book @param $bookName @return stdClass
[ "Create", "address", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L215-L225
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.editAddressBook
public function editAddressBook($id, $newName) { if (empty($newName) || empty($id)) { return $this->handleError('Empty new name or book id'); } $data = array('name' => $newName); $requestResult = $this->sendRequest('addressbooks/' . $id, 'PUT', $data); return $this->handleResult($requestResult); }
php
public function editAddressBook($id, $newName) { if (empty($newName) || empty($id)) { return $this->handleError('Empty new name or book id'); } $data = array('name' => $newName); $requestResult = $this->sendRequest('addressbooks/' . $id, 'PUT', $data); return $this->handleResult($requestResult); }
[ "public", "function", "editAddressBook", "(", "$", "id", ",", "$", "newName", ")", "{", "if", "(", "empty", "(", "$", "newName", ")", "||", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty new name or boo...
Edit address book name @param $id @param $newName @return stdClass
[ "Edit", "address", "book", "name" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L235-L245
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.removeAddressBook
public function removeAddressBook($id) { if (empty($id)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $id, 'DELETE'); return $this->handleResult($requestResult); }
php
public function removeAddressBook($id) { if (empty($id)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $id, 'DELETE'); return $this->handleResult($requestResult); }
[ "public", "function", "removeAddressBook", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", "...
Remove address book @param $id @return stdClass
[ "Remove", "address", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L254-L263
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getBookInfo
public function getBookInfo($id) { if (empty($id)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $id); return $this->handleResult($requestResult); }
php
public function getBookInfo($id) { if (empty($id)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $id); return $this->handleResult($requestResult); }
[ "public", "function", "getBookInfo", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", "sendRe...
Get information about book @param $id @return stdClass
[ "Get", "information", "about", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L295-L304
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getBookVariables
public function getBookVariables($id) { if (empty($id)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $id . '/variables'); return $this->handleResult($requestResult); }
php
public function getBookVariables($id) { if (empty($id)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $id . '/variables'); return $this->handleResult($requestResult); }
[ "public", "function", "getBookVariables", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", "s...
Get variables from book @param $id Address book id. @return stdClass
[ "Get", "variables", "from", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L314-L323
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getEmailsFromBook
public function getEmailsFromBook($id, $limit = null, $offset = null) { if (empty($id)) { return $this->handleError('Empty book id'); } $data = array(); if (null !== $limit) { $data['limit'] = $limit; } if (null !== $offset) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('addressbooks/' . $id . '/emails', 'GET', $data); return $this->handleResult($requestResult); }
php
public function getEmailsFromBook($id, $limit = null, $offset = null) { if (empty($id)) { return $this->handleError('Empty book id'); } $data = array(); if (null !== $limit) { $data['limit'] = $limit; } if (null !== $offset) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('addressbooks/' . $id . '/emails', 'GET', $data); return $this->handleResult($requestResult); }
[ "public", "function", "getEmailsFromBook", "(", "$", "id", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'...
List email addresses from book @param $id @param $limit @param $offset @return stdClass
[ "List", "email", "addresses", "from", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L334-L351
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.addEmails
public function addEmails($bookID, $emails, $additionalParams = []) { if (empty($bookID) || empty($emails)) { return $this->handleError('Empty book id or emails'); } $data = array( 'emails' => json_encode($emails), ); if ($additionalParams) { $data = array_merge($data, $additionalParams); } $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/emails', 'POST', $data); return $this->handleResult($requestResult); }
php
public function addEmails($bookID, $emails, $additionalParams = []) { if (empty($bookID) || empty($emails)) { return $this->handleError('Empty book id or emails'); } $data = array( 'emails' => json_encode($emails), ); if ($additionalParams) { $data = array_merge($data, $additionalParams); } $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/emails', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "addEmails", "(", "$", "bookID", ",", "$", "emails", ",", "$", "additionalParams", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", "||", "empty", "(", "$", "emails", ")", ")", "{", "return", "$", "this", ...
Add new emails to address book @param $bookID @param $emails @param $additionalParams @return stdClass
[ "Add", "new", "emails", "to", "address", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L362-L379