repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
WsdlToPhp/PackageGenerator | src/WsdlHandler/Tag/Tag.php | Tag.isTheParent | public function isTheParent(AbstractTag $tag)
{
/** @var AbstractTag|null $parent */
$parent = $this->getSuitableParent();
return $parent ? $parent->getNode()->isSameNode($tag->getNode()) : false;
} | php | public function isTheParent(AbstractTag $tag)
{
/** @var AbstractTag|null $parent */
$parent = $this->getSuitableParent();
return $parent ? $parent->getNode()->isSameNode($tag->getNode()) : false;
} | [
"public",
"function",
"isTheParent",
"(",
"AbstractTag",
"$",
"tag",
")",
"{",
"/** @var AbstractTag|null $parent */",
"$",
"parent",
"=",
"$",
"this",
"->",
"getSuitableParent",
"(",
")",
";",
"return",
"$",
"parent",
"?",
"$",
"parent",
"->",
"getNode",
"(",... | Checks if the given tag is the same direct parent of this current tag
@param AbstractTag $tag
@return bool | [
"Checks",
"if",
"the",
"given",
"tag",
"is",
"the",
"same",
"direct",
"parent",
"of",
"this",
"current",
"tag"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/WsdlHandler/Tag/Tag.php#L32-L37 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.addMeta | public function addMeta($metaName, $metaValue)
{
if (!is_scalar($metaName) || (!is_scalar($metaValue) && !is_array($metaValue))) {
throw new \InvalidArgumentException(sprintf('Invalid meta name "%s" or value "%s". Please provide scalar meta name and scalar or array meta value.', gettype($metaName), gettype($metaValue)), __LINE__);
}
$metaValue = is_scalar($metaValue) ? ((is_numeric($metaValue) || is_bool($metaValue) ? $metaValue : trim($metaValue))) : $metaValue;
if ((is_scalar($metaValue) && $metaValue !== '') || is_array($metaValue)) {
if (!array_key_exists($metaName, $this->meta)) {
$this->meta[$metaName] = $metaValue;
} elseif (is_array($this->meta[$metaName]) && is_array($metaValue)) {
$this->meta[$metaName] = array_merge($this->meta[$metaName], $metaValue);
} elseif (is_array($this->meta[$metaName])) {
array_push($this->meta[$metaName], $metaValue);
} else {
$this->meta[$metaName] = $metaValue;
}
ksort($this->meta);
}
return $this;
} | php | public function addMeta($metaName, $metaValue)
{
if (!is_scalar($metaName) || (!is_scalar($metaValue) && !is_array($metaValue))) {
throw new \InvalidArgumentException(sprintf('Invalid meta name "%s" or value "%s". Please provide scalar meta name and scalar or array meta value.', gettype($metaName), gettype($metaValue)), __LINE__);
}
$metaValue = is_scalar($metaValue) ? ((is_numeric($metaValue) || is_bool($metaValue) ? $metaValue : trim($metaValue))) : $metaValue;
if ((is_scalar($metaValue) && $metaValue !== '') || is_array($metaValue)) {
if (!array_key_exists($metaName, $this->meta)) {
$this->meta[$metaName] = $metaValue;
} elseif (is_array($this->meta[$metaName]) && is_array($metaValue)) {
$this->meta[$metaName] = array_merge($this->meta[$metaName], $metaValue);
} elseif (is_array($this->meta[$metaName])) {
array_push($this->meta[$metaName], $metaValue);
} else {
$this->meta[$metaName] = $metaValue;
}
ksort($this->meta);
}
return $this;
} | [
"public",
"function",
"addMeta",
"(",
"$",
"metaName",
",",
"$",
"metaValue",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"metaName",
")",
"||",
"(",
"!",
"is_scalar",
"(",
"$",
"metaValue",
")",
"&&",
"!",
"is_array",
"(",
"$",
"metaValue",
")"... | Add meta information to the operation
@uses AbstractModel::getMeta()
@throws \InvalidArgumentException
@param string $metaName
@param mixed $metaValue
@return AbstractModel | [
"Add",
"meta",
"information",
"to",
"the",
"operation"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L147-L166 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.setDocumentation | public function setDocumentation($documentation)
{
return $this->addMeta(self::META_DOCUMENTATION, is_array($documentation) ? $documentation : [
$documentation,
]);
} | php | public function setDocumentation($documentation)
{
return $this->addMeta(self::META_DOCUMENTATION, is_array($documentation) ? $documentation : [
$documentation,
]);
} | [
"public",
"function",
"setDocumentation",
"(",
"$",
"documentation",
")",
"{",
"return",
"$",
"this",
"->",
"addMeta",
"(",
"self",
"::",
"META_DOCUMENTATION",
",",
"is_array",
"(",
"$",
"documentation",
")",
"?",
"$",
"documentation",
":",
"[",
"$",
"docume... | Sets the documentation meta value.
Documentation is set as an array so if multiple documentation nodes are set for an unique element, it will gather them.
@uses AbstractModel::META_DOCUMENTATION
@uses AbstractModel::addMeta()
@param string $documentation the documentation from the WSDL
@return AbstractModel | [
"Sets",
"the",
"documentation",
"meta",
"value",
".",
"Documentation",
"is",
"set",
"as",
"an",
"array",
"so",
"if",
"multiple",
"documentation",
"nodes",
"are",
"set",
"for",
"an",
"unique",
"element",
"it",
"will",
"gather",
"them",
"."
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L224-L229 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.getMetaValue | public function getMetaValue($metaName, $fallback = null)
{
$meta = $this->getMeta();
return array_key_exists($metaName, $meta) ? $meta[$metaName] : $fallback;
} | php | public function getMetaValue($metaName, $fallback = null)
{
$meta = $this->getMeta();
return array_key_exists($metaName, $meta) ? $meta[$metaName] : $fallback;
} | [
"public",
"function",
"getMetaValue",
"(",
"$",
"metaName",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"metaName",
",",
"$",
"meta",
")",
"?",
"$... | Returns a meta value according to its name
@uses AbstractModel::getMeta()
@param string $metaName the meta information name
@param mixed $fallback the fallback value if unset
@return mixed the meta information value | [
"Returns",
"a",
"meta",
"value",
"according",
"to",
"its",
"name"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L237-L241 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.getMetaValueFirstSet | public function getMetaValueFirstSet(array $names, $fallback = null)
{
$meta = $this->getMeta();
foreach ($names as $name) {
if (array_key_exists($name, $meta)) {
return $meta[$name];
}
}
return $fallback;
} | php | public function getMetaValueFirstSet(array $names, $fallback = null)
{
$meta = $this->getMeta();
foreach ($names as $name) {
if (array_key_exists($name, $meta)) {
return $meta[$name];
}
}
return $fallback;
} | [
"public",
"function",
"getMetaValueFirstSet",
"(",
"array",
"$",
"names",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"if",
"... | Returns the value of the first meta value assigned to the name
@param string[] $names the meta names to check
@param mixed $fallback the fallback value if anyone is set
@return mixed the meta information value | [
"Returns",
"the",
"value",
"of",
"the",
"first",
"meta",
"value",
"assigned",
"to",
"the",
"name"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L248-L257 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.getPackagedName | public function getPackagedName($namespaced = false)
{
$nameParts = [];
if ($namespaced && $this->getNamespace() !== '') {
$nameParts[] = sprintf('\%s\\', $this->getNamespace());
}
$cleanName = $this->getCleanName();
if ($this->getGenerator()->getOptionPrefix() !== '') {
$nameParts[] = $this->getGenerator()->getOptionPrefix();
} else {
$cleanName = self::replacePhpReservedKeyword($cleanName);
}
$nameParts[] = ucfirst(self::uniqueName($cleanName, $this->getContextualPart()));
if ($this->getGenerator()->getOptionSuffix() !== '') {
$nameParts[] = $this->getGenerator()->getOptionSuffix();
}
return implode('', $nameParts);
} | php | public function getPackagedName($namespaced = false)
{
$nameParts = [];
if ($namespaced && $this->getNamespace() !== '') {
$nameParts[] = sprintf('\%s\\', $this->getNamespace());
}
$cleanName = $this->getCleanName();
if ($this->getGenerator()->getOptionPrefix() !== '') {
$nameParts[] = $this->getGenerator()->getOptionPrefix();
} else {
$cleanName = self::replacePhpReservedKeyword($cleanName);
}
$nameParts[] = ucfirst(self::uniqueName($cleanName, $this->getContextualPart()));
if ($this->getGenerator()->getOptionSuffix() !== '') {
$nameParts[] = $this->getGenerator()->getOptionSuffix();
}
return implode('', $nameParts);
} | [
"public",
"function",
"getPackagedName",
"(",
"$",
"namespaced",
"=",
"false",
")",
"{",
"$",
"nameParts",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"namespaced",
"&&",
"$",
"this",
"->",
"getNamespace",
"(",
")",
"!==",
"''",
")",
"{",
"$",
"nameParts",
"... | Returns the packaged name
@uses AbstractModel::getNamespace()
@uses AbstractModel::getCleanName()
@uses AbstractModel::getContextualPart()
@uses AbstractModel::uniqueName()
@uses AbstractModel::replacePhpReservedKeyword()
@uses AbstractGeneratorAware::getGenerator()
@uses Generator::getOptionPrefix()
@uses Generator::getOptionSuffix()
@uses AbstractModel::uniqueName() to ensure unique naming of struct case sensitively
@param bool $namespaced
@return string | [
"Returns",
"the",
"packaged",
"name"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L345-L362 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.getSubDirectory | public function getSubDirectory()
{
$subDirectory = '';
if ($this->getGenerator()->getOptionCategory() === GeneratorOptions::VALUE_CAT) {
$subDirectory = $this->getContextualPart();
}
return $subDirectory;
} | php | public function getSubDirectory()
{
$subDirectory = '';
if ($this->getGenerator()->getOptionCategory() === GeneratorOptions::VALUE_CAT) {
$subDirectory = $this->getContextualPart();
}
return $subDirectory;
} | [
"public",
"function",
"getSubDirectory",
"(",
")",
"{",
"$",
"subDirectory",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"getOptionCategory",
"(",
")",
"===",
"GeneratorOptions",
"::",
"VALUE_CAT",
")",
"{",
"$",
"subDirec... | Returns directory where to store class and create it if needed
@uses AbstractGeneratorAware::getGenerator()
@uses AbstractModel::getOptionCategory()
@uses AbstractGeneratorAware::getContextualPart()
@uses GeneratorOptions::VALUE_CAT
@return string | [
"Returns",
"directory",
"where",
"to",
"store",
"class",
"and",
"create",
"it",
"if",
"needed"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L414-L421 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.replacePhpReservedKeyword | public static function replacePhpReservedKeyword($keyword, $context = null)
{
if (PhpReservedKeyword::instance()->is($keyword)) {
if ($context !== null) {
$keywordKey = $keyword . '_' . $context;
if (!array_key_exists($keywordKey, self::$replacedPhpReservedKeywords)) {
self::$replacedPhpReservedKeywords[$keywordKey] = 0;
} else {
self::$replacedPhpReservedKeywords[$keywordKey]++;
}
return '_' . $keyword . (self::$replacedPhpReservedKeywords[$keywordKey] ? '_' . self::$replacedPhpReservedKeywords[$keywordKey] : '');
} else {
return '_' . $keyword;
}
} else {
return $keyword;
}
} | php | public static function replacePhpReservedKeyword($keyword, $context = null)
{
if (PhpReservedKeyword::instance()->is($keyword)) {
if ($context !== null) {
$keywordKey = $keyword . '_' . $context;
if (!array_key_exists($keywordKey, self::$replacedPhpReservedKeywords)) {
self::$replacedPhpReservedKeywords[$keywordKey] = 0;
} else {
self::$replacedPhpReservedKeywords[$keywordKey]++;
}
return '_' . $keyword . (self::$replacedPhpReservedKeywords[$keywordKey] ? '_' . self::$replacedPhpReservedKeywords[$keywordKey] : '');
} else {
return '_' . $keyword;
}
} else {
return $keyword;
}
} | [
"public",
"static",
"function",
"replacePhpReservedKeyword",
"(",
"$",
"keyword",
",",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"PhpReservedKeyword",
"::",
"instance",
"(",
")",
"->",
"is",
"(",
"$",
"keyword",
")",
")",
"{",
"if",
"(",
"$",
"... | Returns a usable keyword for a original keyword
@uses PhpReservedKeyword::instance()
@uses PhpReservedKeyword::is()
@param string $keyword the keyword
@param string $context the context
@return string | [
"Returns",
"a",
"usable",
"keyword",
"for",
"a",
"original",
"keyword"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L450-L467 | train |
WsdlToPhp/PackageGenerator | src/Model/AbstractModel.php | AbstractModel.replaceReservedMethod | public function replaceReservedMethod($methodName, $context = null)
{
if ($this->getReservedMethodsInstance()->is($methodName)) {
if ($context !== null) {
$methodKey = $methodName . '_' . $context;
if (!array_key_exists($methodKey, $this->replacedReservedMethods)) {
$this->replacedReservedMethods[$methodKey] = 0;
} else {
$this->replacedReservedMethods[$methodKey]++;
}
return '_' . $methodName . ($this->replacedReservedMethods[$methodKey] ? '_' . $this->replacedReservedMethods[$methodKey] : '');
} else {
return '_' . $methodName;
}
} else {
return $methodName;
}
} | php | public function replaceReservedMethod($methodName, $context = null)
{
if ($this->getReservedMethodsInstance()->is($methodName)) {
if ($context !== null) {
$methodKey = $methodName . '_' . $context;
if (!array_key_exists($methodKey, $this->replacedReservedMethods)) {
$this->replacedReservedMethods[$methodKey] = 0;
} else {
$this->replacedReservedMethods[$methodKey]++;
}
return '_' . $methodName . ($this->replacedReservedMethods[$methodKey] ? '_' . $this->replacedReservedMethods[$methodKey] : '');
} else {
return '_' . $methodName;
}
} else {
return $methodName;
}
} | [
"public",
"function",
"replaceReservedMethod",
"(",
"$",
"methodName",
",",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getReservedMethodsInstance",
"(",
")",
"->",
"is",
"(",
"$",
"methodName",
")",
")",
"{",
"if",
"(",
"$",
... | Returns a usable method for a original method
@uses PhpReservedKeywords::instance()
@uses PhpReservedKeywords::is()
@param string $methodName the method name
@param string $context the context
@return string | [
"Returns",
"a",
"usable",
"method",
"for",
"a",
"original",
"method"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/AbstractModel.php#L485-L502 | train |
WsdlToPhp/PackageGenerator | src/WsdlHandler/Tag/TagRestriction.php | TagRestriction.hasUnionParent | public function hasUnionParent()
{
return $this->getSuitableParent(false, [
AbstractDocument::TAG_UNION,
], self::MAX_DEEP, true) instanceof TagUnion;
} | php | public function hasUnionParent()
{
return $this->getSuitableParent(false, [
AbstractDocument::TAG_UNION,
], self::MAX_DEEP, true) instanceof TagUnion;
} | [
"public",
"function",
"hasUnionParent",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getSuitableParent",
"(",
"false",
",",
"[",
"AbstractDocument",
"::",
"TAG_UNION",
",",
"]",
",",
"self",
"::",
"MAX_DEEP",
",",
"true",
")",
"instanceof",
"TagUnion",
";",
... | Checks wether this element is contained by an union parent or not
@return bool | [
"Checks",
"wether",
"this",
"element",
"is",
"contained",
"by",
"an",
"union",
"parent",
"or",
"not"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/WsdlHandler/Tag/TagRestriction.php#L52-L57 | train |
WsdlToPhp/PackageGenerator | src/Container/AbstractObjectContainer.php | AbstractObjectContainer.beforeObjectIsStored | protected function beforeObjectIsStored($object)
{
if (!is_object($object)) {
throw new \InvalidArgumentException(sprintf('You must only pass object to this container (%s), "%s" passed as parameter!', get_called_class(), gettype($object)), __LINE__);
}
$instanceOf = $this->objectClass();
if (get_class($object) !== $this->objectClass() && !$object instanceof $instanceOf) {
throw new \InvalidArgumentException(sprintf('Model of type "%s" does not match the object contained by this class: "%s"', get_class($object), $this->objectClass()), __LINE__);
}
} | php | protected function beforeObjectIsStored($object)
{
if (!is_object($object)) {
throw new \InvalidArgumentException(sprintf('You must only pass object to this container (%s), "%s" passed as parameter!', get_called_class(), gettype($object)), __LINE__);
}
$instanceOf = $this->objectClass();
if (get_class($object) !== $this->objectClass() && !$object instanceof $instanceOf) {
throw new \InvalidArgumentException(sprintf('Model of type "%s" does not match the object contained by this class: "%s"', get_class($object), $this->objectClass()), __LINE__);
}
} | [
"protected",
"function",
"beforeObjectIsStored",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'You must only pass object to this container (%s), ... | This method is called before the object has been stored
@throws \InvalidArgumentException
@param mixed $object | [
"This",
"method",
"is",
"called",
"before",
"the",
"object",
"has",
"been",
"stored"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Container/AbstractObjectContainer.php#L116-L125 | train |
WsdlToPhp/PackageGenerator | src/WsdlHandler/Tag/AbstractTag.php | AbstractTag.getSuitableParentTags | protected function getSuitableParentTags(array $additionalTags = [])
{
return array_merge([
WsdlDocument::TAG_ELEMENT,
WsdlDocument::TAG_ATTRIBUTE,
WsdlDocument::TAG_SIMPLE_TYPE,
WsdlDocument::TAG_COMPLEX_TYPE,
], $additionalTags);
} | php | protected function getSuitableParentTags(array $additionalTags = [])
{
return array_merge([
WsdlDocument::TAG_ELEMENT,
WsdlDocument::TAG_ATTRIBUTE,
WsdlDocument::TAG_SIMPLE_TYPE,
WsdlDocument::TAG_COMPLEX_TYPE,
], $additionalTags);
} | [
"protected",
"function",
"getSuitableParentTags",
"(",
"array",
"$",
"additionalTags",
"=",
"[",
"]",
")",
"{",
"return",
"array_merge",
"(",
"[",
"WsdlDocument",
"::",
"TAG_ELEMENT",
",",
"WsdlDocument",
"::",
"TAG_ATTRIBUTE",
",",
"WsdlDocument",
"::",
"TAG_SIMP... | Suitable tags as parent
@param array $additionalTags
@return string[] | [
"Suitable",
"tags",
"as",
"parent"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/WsdlHandler/Tag/AbstractTag.php#L47-L55 | train |
WsdlToPhp/PackageGenerator | src/Parser/Wsdl/AbstractParser.php | AbstractParser.parse | final public function parse()
{
$wsdl = $this->generator->getWsdl();
if ($wsdl instanceof Wsdl) {
$content = $wsdl->getContent();
if ($content instanceof WsdlDocument) {
if ($this->isWsdlParsed($wsdl) === false) {
$this->setWsdlAsParsed($wsdl)->setTags($content->getElementsByName($this->parsingTag()))->parseWsdl($wsdl);
}
foreach ($content->getExternalSchemas() as $schema) {
if ($this->isSchemaParsed($wsdl, $schema) === false) {
$this->setSchemaAsParsed($wsdl, $schema);
$schemaContent = $schema->getContent();
if ($schemaContent instanceof SchemaDocument) {
$this->setTags($schemaContent->getElementsByName($this->parsingTag()))->parseSchema($wsdl, $schema);
}
}
}
}
}
} | php | final public function parse()
{
$wsdl = $this->generator->getWsdl();
if ($wsdl instanceof Wsdl) {
$content = $wsdl->getContent();
if ($content instanceof WsdlDocument) {
if ($this->isWsdlParsed($wsdl) === false) {
$this->setWsdlAsParsed($wsdl)->setTags($content->getElementsByName($this->parsingTag()))->parseWsdl($wsdl);
}
foreach ($content->getExternalSchemas() as $schema) {
if ($this->isSchemaParsed($wsdl, $schema) === false) {
$this->setSchemaAsParsed($wsdl, $schema);
$schemaContent = $schema->getContent();
if ($schemaContent instanceof SchemaDocument) {
$this->setTags($schemaContent->getElementsByName($this->parsingTag()))->parseSchema($wsdl, $schema);
}
}
}
}
}
} | [
"final",
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"wsdl",
"=",
"$",
"this",
"->",
"generator",
"->",
"getWsdl",
"(",
")",
";",
"if",
"(",
"$",
"wsdl",
"instanceof",
"Wsdl",
")",
"{",
"$",
"content",
"=",
"$",
"wsdl",
"->",
"getContent",
"... | The method takes care of looping among WSDLS as much time as it is needed
@see \WsdlToPhp\PackageGenerator\Generator\ParserInterface::parse() | [
"The",
"method",
"takes",
"care",
"of",
"looping",
"among",
"WSDLS",
"as",
"much",
"time",
"as",
"it",
"is",
"needed"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Parser/Wsdl/AbstractParser.php#L47-L67 | train |
WsdlToPhp/PackageGenerator | src/Model/Service.php | Service.addMethod | public function addMethod($methodName, $methodParameterType, $methodReturnType, $methodIsUnique = true)
{
$method = new Method($this->getGenerator(), $methodName, $methodParameterType, $methodReturnType, $this, $methodIsUnique);
$this->methods->add($method);
return $method;
} | php | public function addMethod($methodName, $methodParameterType, $methodReturnType, $methodIsUnique = true)
{
$method = new Method($this->getGenerator(), $methodName, $methodParameterType, $methodReturnType, $this, $methodIsUnique);
$this->methods->add($method);
return $method;
} | [
"public",
"function",
"addMethod",
"(",
"$",
"methodName",
",",
"$",
"methodParameterType",
",",
"$",
"methodReturnType",
",",
"$",
"methodIsUnique",
"=",
"true",
")",
"{",
"$",
"method",
"=",
"new",
"Method",
"(",
"$",
"this",
"->",
"getGenerator",
"(",
"... | Adds a method to the service
@uses Method::setUnique()
@param string $methodName original method name
@param string|array $methodParameterType original parameter type/name
@param string|array $methodReturnType original return type/name
@param bool $methodIsUnique original isUnique value
@return Method | [
"Adds",
"a",
"method",
"to",
"the",
"service"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Service.php#L84-L89 | train |
WsdlToPhp/PackageGenerator | src/Model/Method.php | Method.getMethodName | public function getMethodName()
{
if (empty($this->methodName)) {
$methodName = $this->getCleanName();
if (!$this->isUnique()) {
if (is_string($this->getParameterType())) {
$methodName .= ucfirst($this->getParameterType());
} else {
$methodName .= '_' . md5(var_export($this->getParameterType(), true));
}
}
$context = $this->getOwner()->getPackagedName();
$methodName = $this->replaceReservedMethod($methodName, $context);
$methodName = self::replacePhpReservedKeyword($methodName, $context);
$this->methodName = self::uniqueName($methodName, $this->getOwner()->getPackagedName());
}
return $this->methodName;
} | php | public function getMethodName()
{
if (empty($this->methodName)) {
$methodName = $this->getCleanName();
if (!$this->isUnique()) {
if (is_string($this->getParameterType())) {
$methodName .= ucfirst($this->getParameterType());
} else {
$methodName .= '_' . md5(var_export($this->getParameterType(), true));
}
}
$context = $this->getOwner()->getPackagedName();
$methodName = $this->replaceReservedMethod($methodName, $context);
$methodName = self::replacePhpReservedKeyword($methodName, $context);
$this->methodName = self::uniqueName($methodName, $this->getOwner()->getPackagedName());
}
return $this->methodName;
} | [
"public",
"function",
"getMethodName",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"methodName",
")",
")",
"{",
"$",
"methodName",
"=",
"$",
"this",
"->",
"getCleanName",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isUnique",
... | Returns the name of the method that is used to call the operation
It takes care of the fact that the method might not be the only one named as it is.
@uses Method::getCleanName()
@uses AbstractModel::replacePhpReservedKeyword()
@uses AbstractModel::getOwner()
@uses AbstractModel::getPackagedName()
@uses AbstractModel::uniqueName()
@uses Method::getOwner()
@uses Method::getParameterType()
@uses Method::isUnique()
@return string | [
"Returns",
"the",
"name",
"of",
"the",
"method",
"that",
"is",
"used",
"to",
"call",
"the",
"operation",
"It",
"takes",
"care",
"of",
"the",
"fact",
"that",
"the",
"method",
"might",
"not",
"be",
"the",
"only",
"one",
"named",
"as",
"it",
"is",
"."
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Method.php#L74-L91 | train |
WsdlToPhp/PackageGenerator | src/ConfigurationReader/GeneratorOptions.php | GeneratorOptions.parseOptions | protected function parseOptions($filename)
{
$options = $this->loadYaml($filename);
if (is_array($options)) {
$this->options = $options;
} else {
throw new \InvalidArgumentException(sprintf('Settings contained by "%s" are not valid as the settings are not contained by an array: "%s"', $filename, gettype($options)), __LINE__);
}
return $this;
} | php | protected function parseOptions($filename)
{
$options = $this->loadYaml($filename);
if (is_array($options)) {
$this->options = $options;
} else {
throw new \InvalidArgumentException(sprintf('Settings contained by "%s" are not valid as the settings are not contained by an array: "%s"', $filename, gettype($options)), __LINE__);
}
return $this;
} | [
"protected",
"function",
"parseOptions",
"(",
"$",
"filename",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"loadYaml",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"this",
"->",
"options",
"=",... | Parse options for generator
@param string $filename options's file to parse
@return GeneratorOptions | [
"Parse",
"options",
"for",
"generator"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/ConfigurationReader/GeneratorOptions.php#L70-L79 | train |
WsdlToPhp/PackageGenerator | src/ConfigurationReader/GeneratorOptions.php | GeneratorOptions.getOptionValue | public function getOptionValue($optionName)
{
if (!isset($this->options[$optionName])) {
throw new \InvalidArgumentException(sprintf('Invalid option name "%s", possible options: %s', $optionName, implode(', ', array_keys($this->options))), __LINE__);
}
return array_key_exists('value', $this->options[$optionName]) ? $this->options[$optionName]['value'] : $this->options[$optionName]['default'];
} | php | public function getOptionValue($optionName)
{
if (!isset($this->options[$optionName])) {
throw new \InvalidArgumentException(sprintf('Invalid option name "%s", possible options: %s', $optionName, implode(', ', array_keys($this->options))), __LINE__);
}
return array_key_exists('value', $this->options[$optionName]) ? $this->options[$optionName]['value'] : $this->options[$optionName]['default'];
} | [
"public",
"function",
"getOptionValue",
"(",
"$",
"optionName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"optionName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Inv... | Returns the option value
@throws \InvalidArgumentException
@param string $optionName
@return mixed | [
"Returns",
"the",
"option",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/ConfigurationReader/GeneratorOptions.php#L86-L92 | train |
WsdlToPhp/PackageGenerator | src/ConfigurationReader/GeneratorOptions.php | GeneratorOptions.setOptionValue | public function setOptionValue($optionName, $optionValue, array $values = [])
{
if (!isset($this->options[$optionName])) {
$this->options[$optionName] = [
'value' => $optionValue,
'values' => $values,
];
} elseif (!empty($this->options[$optionName]['values']) && !in_array($optionValue, $this->options[$optionName]['values'], true)) {
throw new \InvalidArgumentException(sprintf('Invalid value "%s" for option "%s", possible values: %s', $optionValue, $optionName, implode(', ', $this->options[$optionName]['values'])), __LINE__);
} else {
$this->options[$optionName]['value'] = $optionValue;
}
return $this;
} | php | public function setOptionValue($optionName, $optionValue, array $values = [])
{
if (!isset($this->options[$optionName])) {
$this->options[$optionName] = [
'value' => $optionValue,
'values' => $values,
];
} elseif (!empty($this->options[$optionName]['values']) && !in_array($optionValue, $this->options[$optionName]['values'], true)) {
throw new \InvalidArgumentException(sprintf('Invalid value "%s" for option "%s", possible values: %s', $optionValue, $optionName, implode(', ', $this->options[$optionName]['values'])), __LINE__);
} else {
$this->options[$optionName]['value'] = $optionValue;
}
return $this;
} | [
"public",
"function",
"setOptionValue",
"(",
"$",
"optionName",
",",
"$",
"optionValue",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"optionName",
"]",
")",
")",
"{",
"... | Allows to add an option and set its value
@throws \InvalidArgumentException
@param string $optionName
@param mixed $optionValue
@param array $values
@return GeneratorOptions | [
"Allows",
"to",
"add",
"an",
"option",
"and",
"set",
"its",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/ConfigurationReader/GeneratorOptions.php#L101-L114 | train |
WsdlToPhp/PackageGenerator | src/ConfigurationReader/GeneratorOptions.php | GeneratorOptions.setAddComments | public function setAddComments(array $addComments = [])
{
/**
* If array is type array("author:john Doe","Release:1",)
*/
$comments = [];
foreach ($addComments as $index => $value) {
if (is_numeric($index) && mb_strpos($value, ':') > 0) {
list($tag, $val) = explode(':', $value);
$comments[$tag] = $val;
} else {
$comments[$index] = $value;
}
}
return $this->setOptionValue(self::ADD_COMMENTS, $comments);
} | php | public function setAddComments(array $addComments = [])
{
/**
* If array is type array("author:john Doe","Release:1",)
*/
$comments = [];
foreach ($addComments as $index => $value) {
if (is_numeric($index) && mb_strpos($value, ':') > 0) {
list($tag, $val) = explode(':', $value);
$comments[$tag] = $val;
} else {
$comments[$index] = $value;
}
}
return $this->setOptionValue(self::ADD_COMMENTS, $comments);
} | [
"public",
"function",
"setAddComments",
"(",
"array",
"$",
"addComments",
"=",
"[",
"]",
")",
"{",
"/**\n * If array is type array(\"author:john Doe\",\"Release:1\",)\n */",
"$",
"comments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"addComments",
"as",
... | Set current add comments option value
@throws \InvalidArgumentException
@param array $addComments
@return GeneratorOptions | [
"Set",
"current",
"add",
"comments",
"option",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/ConfigurationReader/GeneratorOptions.php#L163-L178 | train |
WsdlToPhp/PackageGenerator | src/ConfigurationReader/GeneratorOptions.php | GeneratorOptions.setComposerSettings | public function setComposerSettings(array $composerSettings = [])
{
/**
* If array is type array("config.value:true","require:library/src",)
*/
$settings = [];
foreach ($composerSettings as $index => $value) {
if (is_numeric($index) && mb_strpos($value, ':') > 0) {
$path = implode('', array_slice(explode(':', $value), 0, 1));
$val = implode(':', array_slice(explode(':', $value), 1));
self::dotNotationToArray($path, $val, $settings);
} else {
$settings[$index] = $value;
}
}
return $this->setOptionValue(self::COMPOSER_SETTINGS, $settings);
} | php | public function setComposerSettings(array $composerSettings = [])
{
/**
* If array is type array("config.value:true","require:library/src",)
*/
$settings = [];
foreach ($composerSettings as $index => $value) {
if (is_numeric($index) && mb_strpos($value, ':') > 0) {
$path = implode('', array_slice(explode(':', $value), 0, 1));
$val = implode(':', array_slice(explode(':', $value), 1));
self::dotNotationToArray($path, $val, $settings);
} else {
$settings[$index] = $value;
}
}
return $this->setOptionValue(self::COMPOSER_SETTINGS, $settings);
} | [
"public",
"function",
"setComposerSettings",
"(",
"array",
"$",
"composerSettings",
"=",
"[",
"]",
")",
"{",
"/**\n * If array is type array(\"config.value:true\",\"require:library/src\",)\n */",
"$",
"settings",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"c... | Set current composer settings option value
@throws \InvalidArgumentException
@param array $composerSettings
@return GeneratorOptions | [
"Set",
"current",
"composer",
"settings",
"option",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/ConfigurationReader/GeneratorOptions.php#L589-L605 | train |
WsdlToPhp/PackageGenerator | src/WsdlHandler/Wsdl.php | Wsdl.useParentMethodAndExternals | protected function useParentMethodAndExternals($method, $parameters, $includeExternals = false, $returnOne = false)
{
$result = call_user_func_array([
$this,
sprintf('parent::%s', $method),
], $parameters);
if ($includeExternals === true && (($returnOne === true && $result === null) || $returnOne === false)) {
$result = $this->useExternalSchemas($method, $parameters, $result, $returnOne);
}
return $result;
} | php | protected function useParentMethodAndExternals($method, $parameters, $includeExternals = false, $returnOne = false)
{
$result = call_user_func_array([
$this,
sprintf('parent::%s', $method),
], $parameters);
if ($includeExternals === true && (($returnOne === true && $result === null) || $returnOne === false)) {
$result = $this->useExternalSchemas($method, $parameters, $result, $returnOne);
}
return $result;
} | [
"protected",
"function",
"useParentMethodAndExternals",
"(",
"$",
"method",
",",
"$",
"parameters",
",",
"$",
"includeExternals",
"=",
"false",
",",
"$",
"returnOne",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
... | Handler any method that exist within the parant class,
in addition it handles the case when we want to use the external schemas to search in
@param string $method
@param array $parameters
@param bool $includeExternals
@param bool $returnOne
@return mixed | [
"Handler",
"any",
"method",
"that",
"exist",
"within",
"the",
"parant",
"class",
"in",
"addition",
"it",
"handles",
"the",
"case",
"when",
"we",
"want",
"to",
"use",
"the",
"external",
"schemas",
"to",
"search",
"in"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/WsdlHandler/Wsdl.php#L106-L116 | train |
WsdlToPhp/PackageGenerator | src/Model/StructAttribute.php | StructAttribute.getType | public function getType($useTypeStruct = false)
{
if ($useTypeStruct) {
$typeStruct = $this->getTypeStruct();
if ($typeStruct instanceof Struct) {
$type = $typeStruct->getTopInheritance();
return $type ? $type : $this->type;
}
}
return $this->type;
} | php | public function getType($useTypeStruct = false)
{
if ($useTypeStruct) {
$typeStruct = $this->getTypeStruct();
if ($typeStruct instanceof Struct) {
$type = $typeStruct->getTopInheritance();
return $type ? $type : $this->type;
}
}
return $this->type;
} | [
"public",
"function",
"getType",
"(",
"$",
"useTypeStruct",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"useTypeStruct",
")",
"{",
"$",
"typeStruct",
"=",
"$",
"this",
"->",
"getTypeStruct",
"(",
")",
";",
"if",
"(",
"$",
"typeStruct",
"instanceof",
"Struct"... | Returns the type value
@return string | [
"Returns",
"the",
"type",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/StructAttribute.php#L97-L107 | train |
WsdlToPhp/PackageGenerator | src/Model/StructAttribute.php | StructAttribute.getDefaultValue | public function getDefaultValue()
{
if ($this->isArray() || $this->isList()) {
return [];
}
return Utils::getValueWithinItsType($this->getMetaValueFirstSet([
'default',
'Default',
'DefaultValue',
'defaultValue',
'defaultvalue',
]), $this->getType(true));
} | php | public function getDefaultValue()
{
if ($this->isArray() || $this->isList()) {
return [];
}
return Utils::getValueWithinItsType($this->getMetaValueFirstSet([
'default',
'Default',
'DefaultValue',
'defaultValue',
'defaultvalue',
]), $this->getType(true));
} | [
"public",
"function",
"getDefaultValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isArray",
"(",
")",
"||",
"$",
"this",
"->",
"isList",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"Utils",
"::",
"getValueWithinItsType",
"(",
"$"... | Returns potential default value
@uses AbstractModel::getMetaValueFirstSet()
@uses Utils::getValueWithinItsType()
@uses StructAttribute::getType()
@uses StructAttribute::getContainsElements()
@return mixed | [
"Returns",
"potential",
"default",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/StructAttribute.php#L187-L199 | train |
WsdlToPhp/PackageGenerator | src/WsdlHandler/Tag/AbstractTagImport.php | AbstractTagImport.getLocationAttribute | public function getLocationAttribute()
{
$location = '';
if ($this->hasAttribute(self::ATTRIBUTE_LOCATION)) {
$location = $this->getAttribute(self::ATTRIBUTE_LOCATION)->getValue(true);
} elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)) {
$location = $this->getAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)->getValue(true);
} elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)) {
$location = $this->getAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)->getValue(true);
}
if (!empty($location) && mb_substr($location, 0, 2) === './') {
$location = mb_substr($location, 2);
}
return $location;
} | php | public function getLocationAttribute()
{
$location = '';
if ($this->hasAttribute(self::ATTRIBUTE_LOCATION)) {
$location = $this->getAttribute(self::ATTRIBUTE_LOCATION)->getValue(true);
} elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)) {
$location = $this->getAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)->getValue(true);
} elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)) {
$location = $this->getAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)->getValue(true);
}
if (!empty($location) && mb_substr($location, 0, 2) === './') {
$location = mb_substr($location, 2);
}
return $location;
} | [
"public",
"function",
"getLocationAttribute",
"(",
")",
"{",
"$",
"location",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"self",
"::",
"ATTRIBUTE_LOCATION",
")",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"getAttribute",
"... | Return the correct location attribute value
@return string | [
"Return",
"the",
"correct",
"location",
"attribute",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/WsdlHandler/Tag/AbstractTagImport.php#L23-L37 | train |
WsdlToPhp/PackageGenerator | src/File/Validation/AbstractRule.php | AbstractRule.applyRule | final public function applyRule($parameterName, $value, $itemType = false)
{
$test = $this->testConditions($parameterName, $value, $itemType);
if (!empty($test)) {
$message = $this->exceptionMessageOnTestFailure($parameterName, $value, $itemType);
$this->getMethod()
->addChild($this->validationRuleComment($value))
->addChild(sprintf('if (%s) {', $test))
->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(%s, __LINE__);', $message), 1))
->addChild('}');
unset($message);
Rules::ruleHasBeenAppliedToAttribute($this, $value, $this->getAttribute());
}
unset($test);
} | php | final public function applyRule($parameterName, $value, $itemType = false)
{
$test = $this->testConditions($parameterName, $value, $itemType);
if (!empty($test)) {
$message = $this->exceptionMessageOnTestFailure($parameterName, $value, $itemType);
$this->getMethod()
->addChild($this->validationRuleComment($value))
->addChild(sprintf('if (%s) {', $test))
->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(%s, __LINE__);', $message), 1))
->addChild('}');
unset($message);
Rules::ruleHasBeenAppliedToAttribute($this, $value, $this->getAttribute());
}
unset($test);
} | [
"final",
"public",
"function",
"applyRule",
"(",
"$",
"parameterName",
",",
"$",
"value",
",",
"$",
"itemType",
"=",
"false",
")",
"{",
"$",
"test",
"=",
"$",
"this",
"->",
"testConditions",
"(",
"$",
"parameterName",
",",
"$",
"value",
",",
"$",
"item... | This method has to add the validation rule to the method's body
@param string $parameterName
@param string|string[] $value
@param bool $itemType
@return AbstractRule | [
"This",
"method",
"has",
"to",
"add",
"the",
"validation",
"rule",
"to",
"the",
"method",
"s",
"body"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/File/Validation/AbstractRule.php#L39-L53 | train |
WsdlToPhp/PackageGenerator | src/Generator/GeneratorFiles.php | GeneratorFiles.generateStructsClasses | protected function generateStructsClasses()
{
foreach ($this->getGenerator()->getStructs() as $struct) {
if (!$struct->isStruct()) {
continue;
}
$this->getStructFile($struct)->setModel($struct)->write();
}
return $this;
} | php | protected function generateStructsClasses()
{
foreach ($this->getGenerator()->getStructs() as $struct) {
if (!$struct->isStruct()) {
continue;
}
$this->getStructFile($struct)->setModel($struct)->write();
}
return $this;
} | [
"protected",
"function",
"generateStructsClasses",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"getStructs",
"(",
")",
"as",
"$",
"struct",
")",
"{",
"if",
"(",
"!",
"$",
"struct",
"->",
"isStruct",
"(",
")",
")",
... | Generates structs classes based on structs collected
@return GeneratorFiles | [
"Generates",
"structs",
"classes",
"based",
"on",
"structs",
"collected"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/GeneratorFiles.php#L50-L59 | train |
WsdlToPhp/PackageGenerator | src/Generator/GeneratorFiles.php | GeneratorFiles.generateServicesClasses | protected function generateServicesClasses()
{
foreach ($this->getGenerator()->getServices(true) as $service) {
$file = new ServiceFile($this->generator, $service->getPackagedName());
$file->setModel($service)->write();
}
return $this;
} | php | protected function generateServicesClasses()
{
foreach ($this->getGenerator()->getServices(true) as $service) {
$file = new ServiceFile($this->generator, $service->getPackagedName());
$file->setModel($service)->write();
}
return $this;
} | [
"protected",
"function",
"generateServicesClasses",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"getServices",
"(",
"true",
")",
"as",
"$",
"service",
")",
"{",
"$",
"file",
"=",
"new",
"ServiceFile",
"(",
"$",
"this... | Generates methods by class
@return GeneratorFiles | [
"Generates",
"methods",
"by",
"class"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/GeneratorFiles.php#L79-L86 | train |
WsdlToPhp/PackageGenerator | src/Generator/GeneratorFiles.php | GeneratorFiles.generateTutorialFile | protected function generateTutorialFile()
{
if ($this->generator->getOptionGenerateTutorialFile() === true && $this->getClassmapFile() instanceof ClassMapFile) {
$tutorialFile = new TutorialFile($this->generator, 'tutorial');
$tutorialFile->write();
}
return $this;
} | php | protected function generateTutorialFile()
{
if ($this->generator->getOptionGenerateTutorialFile() === true && $this->getClassmapFile() instanceof ClassMapFile) {
$tutorialFile = new TutorialFile($this->generator, 'tutorial');
$tutorialFile->write();
}
return $this;
} | [
"protected",
"function",
"generateTutorialFile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"generator",
"->",
"getOptionGenerateTutorialFile",
"(",
")",
"===",
"true",
"&&",
"$",
"this",
"->",
"getClassmapFile",
"(",
")",
"instanceof",
"ClassMapFile",
")",
... | Generates tutorial file
@return GeneratorFiles | [
"Generates",
"tutorial",
"file"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/GeneratorFiles.php#L100-L107 | train |
WsdlToPhp/PackageGenerator | src/Model/Struct.php | Struct.getContextualPart | public function getContextualPart()
{
$part = $this->getGenerator()->getOptionStructsFolder();
if ($this->isRestriction()) {
$part = $this->getGenerator()->getOptionEnumsFolder();
} elseif ($this->isArray()) {
$part = $this->getGenerator()->getOptionArraysFolder();
}
return $part;
} | php | public function getContextualPart()
{
$part = $this->getGenerator()->getOptionStructsFolder();
if ($this->isRestriction()) {
$part = $this->getGenerator()->getOptionEnumsFolder();
} elseif ($this->isArray()) {
$part = $this->getGenerator()->getOptionArraysFolder();
}
return $part;
} | [
"public",
"function",
"getContextualPart",
"(",
")",
"{",
"$",
"part",
"=",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"getOptionStructsFolder",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isRestriction",
"(",
")",
")",
"{",
"$",
"part",
"=",... | Returns the contextual part of the class name for the package
@see AbstractModel::getContextualPart()
@uses Struct::isRestriction()
@return string | [
"Returns",
"the",
"contextual",
"part",
"of",
"the",
"class",
"name",
"for",
"the",
"package"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Struct.php#L89-L98 | train |
WsdlToPhp/PackageGenerator | src/Model/Struct.php | Struct.getDocSubPackages | public function getDocSubPackages()
{
$package = self::DOC_SUB_PACKAGE_STRUCTS;
if ($this->isRestriction()) {
$package = self::DOC_SUB_PACKAGE_ENUMERATIONS;
} elseif ($this->isArray()) {
$package = self::DOC_SUB_PACKAGE_ARRAYS;
}
return [
$package,
];
} | php | public function getDocSubPackages()
{
$package = self::DOC_SUB_PACKAGE_STRUCTS;
if ($this->isRestriction()) {
$package = self::DOC_SUB_PACKAGE_ENUMERATIONS;
} elseif ($this->isArray()) {
$package = self::DOC_SUB_PACKAGE_ARRAYS;
}
return [
$package,
];
} | [
"public",
"function",
"getDocSubPackages",
"(",
")",
"{",
"$",
"package",
"=",
"self",
"::",
"DOC_SUB_PACKAGE_STRUCTS",
";",
"if",
"(",
"$",
"this",
"->",
"isRestriction",
"(",
")",
")",
"{",
"$",
"package",
"=",
"self",
"::",
"DOC_SUB_PACKAGE_ENUMERATIONS",
... | Returns the sub package name which the model belongs to
Must be overridden by sub classes
@see AbstractModel::getDocSubPackages()
@uses Struct::isRestriction()
@return array | [
"Returns",
"the",
"sub",
"package",
"name",
"which",
"the",
"model",
"belongs",
"to",
"Must",
"be",
"overridden",
"by",
"sub",
"classes"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Struct.php#L106-L117 | train |
WsdlToPhp/PackageGenerator | src/Model/Struct.php | Struct.getAttributes | public function getAttributes($includeInheritanceAttributes = false, $requiredFirst = false)
{
if ($includeInheritanceAttributes === false && $requiredFirst === false) {
$attributes = $this->attributes;
} else {
$attributes = $this->getAllAttributes($includeInheritanceAttributes, $requiredFirst);
}
return $attributes;
} | php | public function getAttributes($includeInheritanceAttributes = false, $requiredFirst = false)
{
if ($includeInheritanceAttributes === false && $requiredFirst === false) {
$attributes = $this->attributes;
} else {
$attributes = $this->getAllAttributes($includeInheritanceAttributes, $requiredFirst);
}
return $attributes;
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"includeInheritanceAttributes",
"=",
"false",
",",
"$",
"requiredFirst",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"includeInheritanceAttributes",
"===",
"false",
"&&",
"$",
"requiredFirst",
"===",
"false",
")",
"{"... | Returns the attributes of the struct and potentially from the parent class
@uses AbstractModel::getInheritance()
@uses Struct::isStruct()
@uses Struct::getAttributes()
@param bool $includeInheritanceAttributes include the attributes of parent class, default parent attributes are not included. If true, then the array is an associative array containing and index "attribute" for the StructAttribute object and an index "model" for the Struct object.
@param bool $requiredFirst places the required attributes first, then the not required in order to have the _construct method with the required attribute at first
@return StructAttributeContainer | [
"Returns",
"the",
"attributes",
"of",
"the",
"struct",
"and",
"potentially",
"from",
"the",
"parent",
"class"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Struct.php#L147-L155 | train |
WsdlToPhp/PackageGenerator | src/Model/Struct.php | Struct.addAttribute | public function addAttribute($attributeName, $attributeType)
{
if (empty($attributeName) || empty($attributeType)) {
throw new \InvalidArgumentException(sprintf('Attribute name "%s" and/or attribute type "%s" is invalid for Struct "%s"', $attributeName, $attributeType, $this->getName()), __LINE__);
}
if ($this->attributes->getStructAttributeByName($attributeName) === null) {
$structAttribute = new StructAttribute($this->getGenerator(), $attributeName, $attributeType, $this);
$this->attributes->add($structAttribute);
}
return $this;
} | php | public function addAttribute($attributeName, $attributeType)
{
if (empty($attributeName) || empty($attributeType)) {
throw new \InvalidArgumentException(sprintf('Attribute name "%s" and/or attribute type "%s" is invalid for Struct "%s"', $attributeName, $attributeType, $this->getName()), __LINE__);
}
if ($this->attributes->getStructAttributeByName($attributeName) === null) {
$structAttribute = new StructAttribute($this->getGenerator(), $attributeName, $attributeType, $this);
$this->attributes->add($structAttribute);
}
return $this;
} | [
"public",
"function",
"addAttribute",
"(",
"$",
"attributeName",
",",
"$",
"attributeType",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attributeName",
")",
"||",
"empty",
"(",
"$",
"attributeType",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException... | Adds attribute based on its original name
@throws \InvalidArgumentException
@param string $attributeName the attribute name
@param string $attributeType the attribute type
@return Struct | [
"Adds",
"attribute",
"based",
"on",
"its",
"original",
"name"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Struct.php#L242-L252 | train |
WsdlToPhp/PackageGenerator | src/Model/Struct.php | Struct.addValue | public function addValue($value)
{
if ($this->getValue($value) === null) {
// issue #177, rare case: a struct and an enum has the same name and the enum is not detected by the SoapClient,
// then we need to create the enumeration struct in order to deduplicate the two structs
// this is why enumerations has to be parsed before any other elements by the WSDL parsers
if (0 < $this->countOwnAttributes()) {
$enum = new static($this->getGenerator(), $this->getName(), true, true);
$enum
->setInheritance(self::DEFAULT_ENUM_TYPE)
->getValues()->add(new StructValue($enum->getGenerator(), $value, $enum->getValues()->count(), $enum));
$this->getGenerator()->getStructs()->add($enum);
return $enum;
} else {
$this
->setStruct(true)
->setRestriction(true)
->values->add(new StructValue($this->getGenerator(), $value, $this->getValues()->count(), $this));
}
}
return $this;
} | php | public function addValue($value)
{
if ($this->getValue($value) === null) {
// issue #177, rare case: a struct and an enum has the same name and the enum is not detected by the SoapClient,
// then we need to create the enumeration struct in order to deduplicate the two structs
// this is why enumerations has to be parsed before any other elements by the WSDL parsers
if (0 < $this->countOwnAttributes()) {
$enum = new static($this->getGenerator(), $this->getName(), true, true);
$enum
->setInheritance(self::DEFAULT_ENUM_TYPE)
->getValues()->add(new StructValue($enum->getGenerator(), $value, $enum->getValues()->count(), $enum));
$this->getGenerator()->getStructs()->add($enum);
return $enum;
} else {
$this
->setStruct(true)
->setRestriction(true)
->values->add(new StructValue($this->getGenerator(), $value, $this->getValues()->count(), $this));
}
}
return $this;
} | [
"public",
"function",
"addValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getValue",
"(",
"$",
"value",
")",
"===",
"null",
")",
"{",
"// issue #177, rare case: a struct and an enum has the same name and the enum is not detected by the SoapClient,",
... | Adds value to values array
@uses Struct::getValue()
@uses Struct::getValues()
@param mixed $value the original value
@return Struct | [
"Adds",
"value",
"to",
"values",
"array"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Struct.php#L361-L382 | train |
WsdlToPhp/PackageGenerator | src/Model/Struct.php | Struct.getExtends | public function getExtends($short = false)
{
$extends = '';
if ($this->isArray()) {
$extends = $this->getGenerator()->getOptionStructArrayClass();
} elseif (!$this->isRestriction()) {
$extends = $this->getGenerator()->getOptionStructClass();
}
return $short ? Utils::removeNamespace($extends) : $extends;
} | php | public function getExtends($short = false)
{
$extends = '';
if ($this->isArray()) {
$extends = $this->getGenerator()->getOptionStructArrayClass();
} elseif (!$this->isRestriction()) {
$extends = $this->getGenerator()->getOptionStructClass();
}
return $short ? Utils::removeNamespace($extends) : $extends;
} | [
"public",
"function",
"getExtends",
"(",
"$",
"short",
"=",
"false",
")",
"{",
"$",
"extends",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"isArray",
"(",
")",
")",
"{",
"$",
"extends",
"=",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"g... | Allows to define from which class the current model extends
@param bool $short
@return string | [
"Allows",
"to",
"define",
"from",
"which",
"class",
"the",
"current",
"model",
"extends"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/Struct.php#L399-L408 | train |
WsdlToPhp/PackageGenerator | src/File/Validation/Rules.php | Rules.applyRulesFromAttribute | protected function applyRulesFromAttribute($parameterName, $itemType = false)
{
foreach ($this->attribute->getMeta() as $metaName => $metaValue) {
$rule = $this->getRule($metaName);
if ($rule instanceof AbstractRule) {
$rule->applyRule($parameterName, $metaValue, $itemType);
}
}
} | php | protected function applyRulesFromAttribute($parameterName, $itemType = false)
{
foreach ($this->attribute->getMeta() as $metaName => $metaValue) {
$rule = $this->getRule($metaName);
if ($rule instanceof AbstractRule) {
$rule->applyRule($parameterName, $metaValue, $itemType);
}
}
} | [
"protected",
"function",
"applyRulesFromAttribute",
"(",
"$",
"parameterName",
",",
"$",
"itemType",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"attribute",
"->",
"getMeta",
"(",
")",
"as",
"$",
"metaName",
"=>",
"$",
"metaValue",
")",
"{",... | Generic method to apply rules from current model
@param string $parameterName
@param bool $itemType | [
"Generic",
"method",
"to",
"apply",
"rules",
"from",
"current",
"model"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/File/Validation/Rules.php#L77-L85 | train |
WsdlToPhp/PackageGenerator | src/Container/Model/Service.php | Service.addService | public function addService($serviceName, $methodName, $methodParameter, $methodReturn)
{
if (!$this->get($serviceName) instanceof Model) {
$this->add(new Model($this->generator, $serviceName));
}
$serviceMethod = $this->get($serviceName)->getMethod($methodName);
/**
* Service method does not already exist, register it
*/
if (!$serviceMethod instanceof MethodModel) {
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn);
} elseif ($serviceMethod->getParameterType() != $methodParameter) {
/**
* Service method exists with a different signature, register it too by identifying the service functions as non unique functions
*/
$serviceMethod->setUnique(false);
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn, false);
}
return $this;
} | php | public function addService($serviceName, $methodName, $methodParameter, $methodReturn)
{
if (!$this->get($serviceName) instanceof Model) {
$this->add(new Model($this->generator, $serviceName));
}
$serviceMethod = $this->get($serviceName)->getMethod($methodName);
/**
* Service method does not already exist, register it
*/
if (!$serviceMethod instanceof MethodModel) {
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn);
} elseif ($serviceMethod->getParameterType() != $methodParameter) {
/**
* Service method exists with a different signature, register it too by identifying the service functions as non unique functions
*/
$serviceMethod->setUnique(false);
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn, false);
}
return $this;
} | [
"public",
"function",
"addService",
"(",
"$",
"serviceName",
",",
"$",
"methodName",
",",
"$",
"methodParameter",
",",
"$",
"methodReturn",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"get",
"(",
"$",
"serviceName",
")",
"instanceof",
"Model",
")",
"{",... | Adds a service
@param string $serviceName the service name to which add the method
@param string $methodName the original function name
@param string|array $methodParameter the original parameter name
@param string|array $methodReturn the original return name
@return Service | [
"Adds",
"a",
"service"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Container/Model/Service.php#L26-L45 | train |
WsdlToPhp/PackageGenerator | src/Parser/SoapClient/Structs.php | Structs.parse | public function parse()
{
$types = $this->getGenerator()
->getSoapClient()
->getSoapClient()
->getSoapClient()
->__getTypes();
foreach ($types as $type) {
$this->parseType($type);
}
} | php | public function parse()
{
$types = $this->getGenerator()
->getSoapClient()
->getSoapClient()
->getSoapClient()
->__getTypes();
foreach ($types as $type) {
$this->parseType($type);
}
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"getSoapClient",
"(",
")",
"->",
"getSoapClient",
"(",
")",
"->",
"getSoapClient",
"(",
")",
"->",
"__getTypes",
"(",
")",
";",
"foreach... | Parses the SoapClient types
@see \WsdlToPhp\PackageGenerator\Parser\ParserInterface::parse() | [
"Parses",
"the",
"SoapClient",
"types"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Parser/SoapClient/Structs.php#L31-L41 | train |
WsdlToPhp/PackageGenerator | src/Parser/SoapClient/Structs.php | Structs.parseUnionStruct | protected function parseUnionStruct($typeDef)
{
$typeDefCount = count($typeDef);
if ($typeDefCount === 3) {
$unionName = $typeDef[1];
$unionTypes = array_filter(explode(',', $typeDef[2]), function ($type) {
return !empty($type);
});
sort($unionTypes);
$this->getGenerator()->getStructs()->addUnionStruct($unionName, $unionTypes);
}
} | php | protected function parseUnionStruct($typeDef)
{
$typeDefCount = count($typeDef);
if ($typeDefCount === 3) {
$unionName = $typeDef[1];
$unionTypes = array_filter(explode(',', $typeDef[2]), function ($type) {
return !empty($type);
});
sort($unionTypes);
$this->getGenerator()->getStructs()->addUnionStruct($unionName, $unionTypes);
}
} | [
"protected",
"function",
"parseUnionStruct",
"(",
"$",
"typeDef",
")",
"{",
"$",
"typeDefCount",
"=",
"count",
"(",
"$",
"typeDef",
")",
";",
"if",
"(",
"$",
"typeDefCount",
"===",
"3",
")",
"{",
"$",
"unionName",
"=",
"$",
"typeDef",
"[",
"1",
"]",
... | union types are passed such as ",dateTime,time" or ",PMS_ResStatusType,TransactionActionType,UpperCaseAlphaLength1to2"
@param array $typeDef | [
"union",
"types",
"are",
"passed",
"such",
"as",
"dateTime",
"time",
"or",
"PMS_ResStatusType",
"TransactionActionType",
"UpperCaseAlphaLength1to2"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Parser/SoapClient/Structs.php#L83-L94 | train |
WsdlToPhp/PackageGenerator | src/Parser/SoapClient/Structs.php | Structs.cleanType | protected static function cleanType($type)
{
$type = str_replace([
"\r",
"\n",
"\t",
'{',
'}',
'[',
']',
';',
], '', $type);
$type = preg_replace('/[\s]+/', ' ', $type);
return trim($type);
} | php | protected static function cleanType($type)
{
$type = str_replace([
"\r",
"\n",
"\t",
'{',
'}',
'[',
']',
';',
], '', $type);
$type = preg_replace('/[\s]+/', ' ', $type);
return trim($type);
} | [
"protected",
"static",
"function",
"cleanType",
"(",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"str_replace",
"(",
"[",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
",",
"'{'",
",",
"'}'",
",",
"'['",
",",
"']'",
",",
"';'",
",",
"]",
",",
"''",
",",
... | Remove useless break line, tabs
Remove curly braces
Remove brackets
Adds space before semicolon to parse it
Remove duplicated spaces
@param string $type
@return string | [
"Remove",
"useless",
"break",
"line",
"tabs",
"Remove",
"curly",
"braces",
"Remove",
"brackets",
"Adds",
"space",
"before",
"semicolon",
"to",
"parse",
"it",
"Remove",
"duplicated",
"spaces"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Parser/SoapClient/Structs.php#L104-L118 | train |
WsdlToPhp/PackageGenerator | src/Parser/Wsdl/AbstractTagParser.php | AbstractTagParser.getModel | protected function getModel(Tag $tag, $type = '')
{
switch ($tag->getName()) {
case WsdlDocument::TAG_OPERATION:
$model = $this->getMethodByName($tag->getAttributeName());
break;
default:
if (empty($type)) {
$model = $this->getStructByName($tag->getAttributeName());
} else {
$model = $this->getStructByNameAndType($tag->getAttributeName(), $type);
}
break;
}
return $model;
} | php | protected function getModel(Tag $tag, $type = '')
{
switch ($tag->getName()) {
case WsdlDocument::TAG_OPERATION:
$model = $this->getMethodByName($tag->getAttributeName());
break;
default:
if (empty($type)) {
$model = $this->getStructByName($tag->getAttributeName());
} else {
$model = $this->getStructByNameAndType($tag->getAttributeName(), $type);
}
break;
}
return $model;
} | [
"protected",
"function",
"getModel",
"(",
"Tag",
"$",
"tag",
",",
"$",
"type",
"=",
"''",
")",
"{",
"switch",
"(",
"$",
"tag",
"->",
"getName",
"(",
")",
")",
"{",
"case",
"WsdlDocument",
"::",
"TAG_OPERATION",
":",
"$",
"model",
"=",
"$",
"this",
... | Return the model on which the method will be called
@param Tag $tag
@param string $type can be passed to specify the Struct type (inheritance)
@return Struct|Method|null | [
"Return",
"the",
"model",
"on",
"which",
"the",
"method",
"will",
"be",
"called"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Parser/Wsdl/AbstractTagParser.php#L32-L47 | train |
WsdlToPhp/PackageGenerator | src/Parser/Wsdl/AbstractTagParser.php | AbstractTagParser.parseTagAttributeValue | protected function parseTagAttributeValue(AttributeHandler $tagAttribute, AbstractModel $model)
{
if (!$model instanceof StructValue) {
$model->addMeta($tagAttribute->getName(), $tagAttribute->getValue(true));
}
} | php | protected function parseTagAttributeValue(AttributeHandler $tagAttribute, AbstractModel $model)
{
if (!$model instanceof StructValue) {
$model->addMeta($tagAttribute->getName(), $tagAttribute->getValue(true));
}
} | [
"protected",
"function",
"parseTagAttributeValue",
"(",
"AttributeHandler",
"$",
"tagAttribute",
",",
"AbstractModel",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"StructValue",
")",
"{",
"$",
"model",
"->",
"addMeta",
"(",
"$",
"tagAtt... | Enumeration does not need its own value as meta information, it's like the name for struct attribute
@param AttributeHandler $tagAttribute
@param AbstractModel $model | [
"Enumeration",
"does",
"not",
"need",
"its",
"own",
"value",
"as",
"meta",
"information",
"it",
"s",
"like",
"the",
"name",
"for",
"struct",
"attribute"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Parser/Wsdl/AbstractTagParser.php#L167-L172 | train |
WsdlToPhp/PackageGenerator | src/WsdlHandler/Tag/TagDocumentation.php | TagDocumentation.getSuitableParent | public function getSuitableParent($checkName = true, array $additionalTags = [], $maxDeep = self::MAX_DEEP, $strict = false)
{
if ($strict === false) {
$enumerationTag = $this->getStrictParent(WsdlDocument::TAG_ENUMERATION);
if ($enumerationTag instanceof TagEnumeration) {
return $enumerationTag;
}
}
return parent::getSuitableParent($checkName, $additionalTags, $maxDeep, $strict);
} | php | public function getSuitableParent($checkName = true, array $additionalTags = [], $maxDeep = self::MAX_DEEP, $strict = false)
{
if ($strict === false) {
$enumerationTag = $this->getStrictParent(WsdlDocument::TAG_ENUMERATION);
if ($enumerationTag instanceof TagEnumeration) {
return $enumerationTag;
}
}
return parent::getSuitableParent($checkName, $additionalTags, $maxDeep, $strict);
} | [
"public",
"function",
"getSuitableParent",
"(",
"$",
"checkName",
"=",
"true",
",",
"array",
"$",
"additionalTags",
"=",
"[",
"]",
",",
"$",
"maxDeep",
"=",
"self",
"::",
"MAX_DEEP",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"strict",... | Finds parent node of this documentation node without taking care of the name attribute for enumeration.
This case is managed first because enumerations are contained by elements and
the method could climb to its parent without stopping on the enumeration tag.
Indeed, depending on the node, it may contain or not the attribute named "name" so we have to split each case.
@see \WsdlToPhp\PackageGenerator\WsdlHandler\Tag\AbstractTag::getSuitableParent() | [
"Finds",
"parent",
"node",
"of",
"this",
"documentation",
"node",
"without",
"taking",
"care",
"of",
"the",
"name",
"attribute",
"for",
"enumeration",
".",
"This",
"case",
"is",
"managed",
"first",
"because",
"enumerations",
"are",
"contained",
"by",
"elements",... | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/WsdlHandler/Tag/TagDocumentation.php#L23-L32 | train |
WsdlToPhp/PackageGenerator | src/Generator/Utils.php | Utils.getPart | public static function getPart($optionValue, $string)
{
$elementType = '';
$string = str_replace('_', '', $string);
$string = preg_replace('/([0-9])/', '', $string);
if (!empty($string)) {
switch ($optionValue) {
case GeneratorOptions::VALUE_END:
$parts = preg_split('/[A-Z]/', ucfirst($string));
$partsCount = count($parts);
if (!empty($parts[$partsCount - 1])) {
$elementType = mb_substr($string, mb_strrpos($string, implode('', array_slice($parts, -1))) - 1);
} else {
for ($i = $partsCount - 1; $i >= 0; $i--) {
$part = trim($parts[$i]);
if (!empty($part)) {
break;
}
}
$elementType = mb_substr($string, ((count($parts) - 2 - $i) + 1) * -1);
}
break;
case GeneratorOptions::VALUE_START:
$parts = preg_split('/[A-Z]/', ucfirst($string));
$partsCount = count($parts);
if (empty($parts[0]) && !empty($parts[1])) {
$elementType = mb_substr($string, 0, mb_strlen($parts[1]) + 1);
} else {
for ($i = 0; $i < $partsCount; $i++) {
$part = trim($parts[$i]);
if (!empty($part)) {
break;
}
}
$elementType = mb_substr($string, 0, $i);
}
break;
case GeneratorOptions::VALUE_NONE:
$elementType = $string;
break;
default:
break;
}
}
return $elementType;
} | php | public static function getPart($optionValue, $string)
{
$elementType = '';
$string = str_replace('_', '', $string);
$string = preg_replace('/([0-9])/', '', $string);
if (!empty($string)) {
switch ($optionValue) {
case GeneratorOptions::VALUE_END:
$parts = preg_split('/[A-Z]/', ucfirst($string));
$partsCount = count($parts);
if (!empty($parts[$partsCount - 1])) {
$elementType = mb_substr($string, mb_strrpos($string, implode('', array_slice($parts, -1))) - 1);
} else {
for ($i = $partsCount - 1; $i >= 0; $i--) {
$part = trim($parts[$i]);
if (!empty($part)) {
break;
}
}
$elementType = mb_substr($string, ((count($parts) - 2 - $i) + 1) * -1);
}
break;
case GeneratorOptions::VALUE_START:
$parts = preg_split('/[A-Z]/', ucfirst($string));
$partsCount = count($parts);
if (empty($parts[0]) && !empty($parts[1])) {
$elementType = mb_substr($string, 0, mb_strlen($parts[1]) + 1);
} else {
for ($i = 0; $i < $partsCount; $i++) {
$part = trim($parts[$i]);
if (!empty($part)) {
break;
}
}
$elementType = mb_substr($string, 0, $i);
}
break;
case GeneratorOptions::VALUE_NONE:
$elementType = $string;
break;
default:
break;
}
}
return $elementType;
} | [
"public",
"static",
"function",
"getPart",
"(",
"$",
"optionValue",
",",
"$",
"string",
")",
"{",
"$",
"elementType",
"=",
"''",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'_'",
",",
"''",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_re... | Gets upper case word among a string from the end or from the beginning part
@param string $optionValue
@param string $string the string from which we can extract the part
@return string | [
"Gets",
"upper",
"case",
"word",
"among",
"a",
"string",
"from",
"the",
"end",
"or",
"from",
"the",
"beginning",
"part"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Utils.php#L15-L60 | train |
WsdlToPhp/PackageGenerator | src/Generator/Utils.php | Utils.getContentFromUrl | public static function getContentFromUrl($url, $basicAuthLogin = null, $basicAuthPassword = null, $proxyHost = null, $proxyPort = null, $proxyLogin = null, $proxyPassword = null, array $contextOptions = [])
{
$context = null;
$options = self::getStreamContextOptions($basicAuthLogin, $basicAuthPassword, $proxyHost, $proxyPort, $proxyLogin, $proxyPassword, $contextOptions);
if (!empty($options)) {
$context = stream_context_create($options);
}
return file_get_contents($url, false, $context);
} | php | public static function getContentFromUrl($url, $basicAuthLogin = null, $basicAuthPassword = null, $proxyHost = null, $proxyPort = null, $proxyLogin = null, $proxyPassword = null, array $contextOptions = [])
{
$context = null;
$options = self::getStreamContextOptions($basicAuthLogin, $basicAuthPassword, $proxyHost, $proxyPort, $proxyLogin, $proxyPassword, $contextOptions);
if (!empty($options)) {
$context = stream_context_create($options);
}
return file_get_contents($url, false, $context);
} | [
"public",
"static",
"function",
"getContentFromUrl",
"(",
"$",
"url",
",",
"$",
"basicAuthLogin",
"=",
"null",
",",
"$",
"basicAuthPassword",
"=",
"null",
",",
"$",
"proxyHost",
"=",
"null",
",",
"$",
"proxyPort",
"=",
"null",
",",
"$",
"proxyLogin",
"=",
... | Get content from url using a proxy or not
@param string $url
@param string $basicAuthLogin
@param string $basicAuthPassword
@param string $proxyHost
@param string $proxyPort
@param string $proxyLogin
@param string $proxyPassword
@param array $contextOptions
@return string | [
"Get",
"content",
"from",
"url",
"using",
"a",
"proxy",
"or",
"not"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Utils.php#L73-L81 | train |
WsdlToPhp/PackageGenerator | src/Generator/Utils.php | Utils.saveSchemas | public static function saveSchemas($destinationFolder, $schemasFolder, $schemasUrl, $content)
{
if (($schemasFolder === null) || empty($schemasFolder)) {
// if null or empty schemas folder was provided
// default schemas folder will be wsdl
$schemasFolder = 'wsdl';
}
$schemasPath = rtrim($destinationFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . rtrim($schemasFolder, DIRECTORY_SEPARATOR);
// Here we must cover all possible variants
if ((mb_strpos(mb_strtolower($schemasUrl), '.wsdl') !== false) || (mb_strpos(mb_strtolower($schemasUrl), '.xsd') !== false) || (mb_strpos(mb_strtolower($schemasUrl), '.xml') !== false)) {
$filename = basename($schemasUrl);
} else {
// if $url is like http://example.com/index.php?WSDL default filename will be schema.wsdl
$filename = 'schema.wsdl';
}
self::createDirectory($schemasPath);
file_put_contents($schemasPath . DIRECTORY_SEPARATOR . $filename, $content);
return $schemasPath . DIRECTORY_SEPARATOR . $filename;
} | php | public static function saveSchemas($destinationFolder, $schemasFolder, $schemasUrl, $content)
{
if (($schemasFolder === null) || empty($schemasFolder)) {
// if null or empty schemas folder was provided
// default schemas folder will be wsdl
$schemasFolder = 'wsdl';
}
$schemasPath = rtrim($destinationFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . rtrim($schemasFolder, DIRECTORY_SEPARATOR);
// Here we must cover all possible variants
if ((mb_strpos(mb_strtolower($schemasUrl), '.wsdl') !== false) || (mb_strpos(mb_strtolower($schemasUrl), '.xsd') !== false) || (mb_strpos(mb_strtolower($schemasUrl), '.xml') !== false)) {
$filename = basename($schemasUrl);
} else {
// if $url is like http://example.com/index.php?WSDL default filename will be schema.wsdl
$filename = 'schema.wsdl';
}
self::createDirectory($schemasPath);
file_put_contents($schemasPath . DIRECTORY_SEPARATOR . $filename, $content);
return $schemasPath . DIRECTORY_SEPARATOR . $filename;
} | [
"public",
"static",
"function",
"saveSchemas",
"(",
"$",
"destinationFolder",
",",
"$",
"schemasFolder",
",",
"$",
"schemasUrl",
",",
"$",
"content",
")",
"{",
"if",
"(",
"(",
"$",
"schemasFolder",
"===",
"null",
")",
"||",
"empty",
"(",
"$",
"schemasFolde... | Save schemas to schemasFolder
Filename will be extracted from schemasUrl or default schema.wsdl will be used
@param string $destinationFolder
@param string $schemasFolder
@param string $schemasUrl
@param string $content
@return string | [
"Save",
"schemas",
"to",
"schemasFolder",
"Filename",
"will",
"be",
"extracted",
"from",
"schemasUrl",
"or",
"default",
"schema",
".",
"wsdl",
"will",
"be",
"used"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Utils.php#L257-L275 | train |
WsdlToPhp/PackageGenerator | src/Model/StructValue.php | StructValue.getCleanName | public function getCleanName($keepMultipleUnderscores = false)
{
if ($this->getGenerator()->getOptionGenericConstantsNames()) {
return 'ENUM_VALUE_' . $this->getIndex();
} else {
$nameWithSeparatedWords = $this->getNameWithSeparatedWords($keepMultipleUnderscores);
$key = self::constantSuffix($this->getOwner()->getName(), $nameWithSeparatedWords, $this->getIndex());
return 'VALUE_' . mb_strtoupper($nameWithSeparatedWords . ($key ? '_' . $key : ''));
}
} | php | public function getCleanName($keepMultipleUnderscores = false)
{
if ($this->getGenerator()->getOptionGenericConstantsNames()) {
return 'ENUM_VALUE_' . $this->getIndex();
} else {
$nameWithSeparatedWords = $this->getNameWithSeparatedWords($keepMultipleUnderscores);
$key = self::constantSuffix($this->getOwner()->getName(), $nameWithSeparatedWords, $this->getIndex());
return 'VALUE_' . mb_strtoupper($nameWithSeparatedWords . ($key ? '_' . $key : ''));
}
} | [
"public",
"function",
"getCleanName",
"(",
"$",
"keepMultipleUnderscores",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getGenerator",
"(",
")",
"->",
"getOptionGenericConstantsNames",
"(",
")",
")",
"{",
"return",
"'ENUM_VALUE_'",
".",
"$",
"this",
... | Returns the name of the value as constant
@see AbstractModel::getCleanName()
@uses AbstractModel::getCleanName()
@uses AbstractModel::getName()
@uses AbstractModel::getOwner()
@uses StructValue::constantSuffix()
@uses StructValue::getIndex()
@uses StructValue::getOwner()
@uses Generator::getOptionGenericConstantsNames()
@param bool $keepMultipleUnderscores optional, allows to keep the multiple consecutive underscores
@return string | [
"Returns",
"the",
"name",
"of",
"the",
"value",
"as",
"constant"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/StructValue.php#L61-L70 | train |
WsdlToPhp/PackageGenerator | src/Model/StructValue.php | StructValue.setIndex | public function setIndex($index)
{
if (!is_int($index) || $index < 0) {
throw new \InvalidArgumentException(sprintf('The value\'s index must be a positive integer, "%s" given', var_export($index, true)));
}
$this->index = $index;
return $this;
} | php | public function setIndex($index)
{
if (!is_int($index) || $index < 0) {
throw new \InvalidArgumentException(sprintf('The value\'s index must be a positive integer, "%s" given', var_export($index, true)));
}
$this->index = $index;
return $this;
} | [
"public",
"function",
"setIndex",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"index",
")",
"||",
"$",
"index",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The value\\'s index must be a ... | Sets the index attribute value
@throws \InvalidArgumentException
@param int $index
@return StructValue | [
"Sets",
"the",
"index",
"attribute",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/StructValue.php#L103-L110 | train |
WsdlToPhp/PackageGenerator | src/Model/StructValue.php | StructValue.constantSuffix | protected static function constantSuffix($structName, $value, $index)
{
$key = mb_strtoupper($structName . '_' . $value);
$indexedKey = $key . '_' . $index;
if (array_key_exists($indexedKey, self::$uniqueConstants)) {
return self::$uniqueConstants[$indexedKey];
} elseif (!array_key_exists($key, self::$uniqueConstants)) {
self::$uniqueConstants[$key] = 0;
} else {
self::$uniqueConstants[$key]++;
}
self::$uniqueConstants[$indexedKey] = self::$uniqueConstants[$key];
return self::$uniqueConstants[$key];
} | php | protected static function constantSuffix($structName, $value, $index)
{
$key = mb_strtoupper($structName . '_' . $value);
$indexedKey = $key . '_' . $index;
if (array_key_exists($indexedKey, self::$uniqueConstants)) {
return self::$uniqueConstants[$indexedKey];
} elseif (!array_key_exists($key, self::$uniqueConstants)) {
self::$uniqueConstants[$key] = 0;
} else {
self::$uniqueConstants[$key]++;
}
self::$uniqueConstants[$indexedKey] = self::$uniqueConstants[$key];
return self::$uniqueConstants[$key];
} | [
"protected",
"static",
"function",
"constantSuffix",
"(",
"$",
"structName",
",",
"$",
"value",
",",
"$",
"index",
")",
"{",
"$",
"key",
"=",
"mb_strtoupper",
"(",
"$",
"structName",
".",
"'_'",
".",
"$",
"value",
")",
";",
"$",
"indexedKey",
"=",
"$",... | Returns the index which has to be added at the end of natural constant name defined with the value cleaned
Allows to avoid multiple constant name to be identical
@param string $structName the struct name
@param string $value the value
@param int $index the position of the value
@return int | [
"Returns",
"the",
"index",
"which",
"has",
"to",
"be",
"added",
"at",
"the",
"end",
"of",
"natural",
"constant",
"name",
"defined",
"with",
"the",
"value",
"cleaned",
"Allows",
"to",
"avoid",
"multiple",
"constant",
"name",
"to",
"be",
"identical"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Model/StructValue.php#L119-L132 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.getServiceMethod | public function getServiceMethod($methodName)
{
return $this->getService($this->getServiceName($methodName)) instanceof Service ? $this->getService($this->getServiceName($methodName))->getMethod($methodName) : null;
} | php | public function getServiceMethod($methodName)
{
return $this->getService($this->getServiceName($methodName)) instanceof Service ? $this->getService($this->getServiceName($methodName))->getMethod($methodName) : null;
} | [
"public",
"function",
"getServiceMethod",
"(",
"$",
"methodName",
")",
"{",
"return",
"$",
"this",
"->",
"getService",
"(",
"$",
"this",
"->",
"getServiceName",
"(",
"$",
"methodName",
")",
")",
"instanceof",
"Service",
"?",
"$",
"this",
"->",
"getService",
... | Returns the method
@uses Generator::getServiceName()
@uses Generator::getService()
@uses Service::getMethod()
@param string $methodName the original function name
@return Method|null | [
"Returns",
"the",
"method"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L233-L236 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.getOptionPrefix | public function getOptionPrefix($ucFirst = true)
{
return $ucFirst ? ucfirst($this->getOptions()->getPrefix()) : $this->getOptions()->getPrefix();
} | php | public function getOptionPrefix($ucFirst = true)
{
return $ucFirst ? ucfirst($this->getOptions()->getPrefix()) : $this->getOptions()->getPrefix();
} | [
"public",
"function",
"getOptionPrefix",
"(",
"$",
"ucFirst",
"=",
"true",
")",
"{",
"return",
"$",
"ucFirst",
"?",
"ucfirst",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getPrefix",
"(",
")",
")",
":",
"$",
"this",
"->",
"getOptions",
"(",
... | Gets the package name prefix
@param bool $ucFirst ucfirst package name prefix or not
@return string | [
"Gets",
"the",
"package",
"name",
"prefix"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L467-L470 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.getOptionSuffix | public function getOptionSuffix($ucFirst = true)
{
return $ucFirst ? ucfirst($this->getOptions()->getSuffix()) : $this->getOptions()->getSuffix();
} | php | public function getOptionSuffix($ucFirst = true)
{
return $ucFirst ? ucfirst($this->getOptions()->getSuffix()) : $this->getOptions()->getSuffix();
} | [
"public",
"function",
"getOptionSuffix",
"(",
"$",
"ucFirst",
"=",
"true",
")",
"{",
"return",
"$",
"ucFirst",
"?",
"ucfirst",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getSuffix",
"(",
")",
")",
":",
"$",
"this",
"->",
"getOptions",
"(",
... | Gets the package name suffix
@param bool $ucFirst ucfirst package name suffix or not
@return string | [
"Gets",
"the",
"package",
"name",
"suffix"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L486-L489 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.getOptionDestination | public function getOptionDestination()
{
$destination = $this->options->getDestination();
if (!empty($destination)) {
$destination = rtrim($destination, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
return $destination;
} | php | public function getOptionDestination()
{
$destination = $this->options->getDestination();
if (!empty($destination)) {
$destination = rtrim($destination, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
return $destination;
} | [
"public",
"function",
"getOptionDestination",
"(",
")",
"{",
"$",
"destination",
"=",
"$",
"this",
"->",
"options",
"->",
"getDestination",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"destination",
"=",
"rtrim",
... | Gets the optionDestination value
@return string | [
"Gets",
"the",
"optionDestination",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L631-L638 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.setOptionDestination | public function setOptionDestination($optionDestination)
{
if (!empty($optionDestination)) {
$this->options->setDestination(rtrim($optionDestination, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
} else {
throw new \InvalidArgumentException('Package\'s destination can\'t be empty', __LINE__);
}
return $this;
} | php | public function setOptionDestination($optionDestination)
{
if (!empty($optionDestination)) {
$this->options->setDestination(rtrim($optionDestination, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
} else {
throw new \InvalidArgumentException('Package\'s destination can\'t be empty', __LINE__);
}
return $this;
} | [
"public",
"function",
"setOptionDestination",
"(",
"$",
"optionDestination",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"optionDestination",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"setDestination",
"(",
"rtrim",
"(",
"$",
"optionDestination",
"... | Sets the optionDestination value
@param string $optionDestination
@return Generator | [
"Sets",
"the",
"optionDestination",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L644-L652 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.setOptionSoapOptions | public function setOptionSoapOptions($optionSoapOptions)
{
$this->options->setSoapOptions($optionSoapOptions);
if ($this->soapClient) {
$this->soapClient->initSoapClient();
}
return $this;
} | php | public function setOptionSoapOptions($optionSoapOptions)
{
$this->options->setSoapOptions($optionSoapOptions);
if ($this->soapClient) {
$this->soapClient->initSoapClient();
}
return $this;
} | [
"public",
"function",
"setOptionSoapOptions",
"(",
"$",
"optionSoapOptions",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"setSoapOptions",
"(",
"$",
"optionSoapOptions",
")",
";",
"if",
"(",
"$",
"this",
"->",
"soapClient",
")",
"{",
"$",
"this",
"->",
"... | Sets the optionSoapOptions value
@param array $optionSoapOptions
@return Generator | [
"Sets",
"the",
"optionSoapOptions",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L684-L691 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.setOptionComposerName | public function setOptionComposerName($optionComposerName)
{
if (!empty($optionComposerName)) {
$this->options->setComposerName($optionComposerName);
} else {
throw new \InvalidArgumentException('Package\'s composer name can\'t be empty', __LINE__);
}
return $this;
} | php | public function setOptionComposerName($optionComposerName)
{
if (!empty($optionComposerName)) {
$this->options->setComposerName($optionComposerName);
} else {
throw new \InvalidArgumentException('Package\'s composer name can\'t be empty', __LINE__);
}
return $this;
} | [
"public",
"function",
"setOptionComposerName",
"(",
"$",
"optionComposerName",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"optionComposerName",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"setComposerName",
"(",
"$",
"optionComposerName",
")",
";",
... | Sets the optionComposerName value
@param string $optionComposerName
@return Generator | [
"Sets",
"the",
"optionComposerName",
"value"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L705-L713 | train |
WsdlToPhp/PackageGenerator | src/Generator/Generator.php | Generator.addSchemaToWsdl | public function addSchemaToWsdl(Wsdl $wsdl, $schemaLocation)
{
if (!empty($schemaLocation) && $wsdl->getContent() instanceof WsdlDocument && $wsdl->getContent()->getExternalSchema($schemaLocation) === null) {
$wsdl->getContent()->addExternalSchema(new Schema($wsdl->getGenerator(), $schemaLocation, $this->getUrlContent($schemaLocation)));
}
return $this;
} | php | public function addSchemaToWsdl(Wsdl $wsdl, $schemaLocation)
{
if (!empty($schemaLocation) && $wsdl->getContent() instanceof WsdlDocument && $wsdl->getContent()->getExternalSchema($schemaLocation) === null) {
$wsdl->getContent()->addExternalSchema(new Schema($wsdl->getGenerator(), $schemaLocation, $this->getUrlContent($schemaLocation)));
}
return $this;
} | [
"public",
"function",
"addSchemaToWsdl",
"(",
"Wsdl",
"$",
"wsdl",
",",
"$",
"schemaLocation",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"schemaLocation",
")",
"&&",
"$",
"wsdl",
"->",
"getContent",
"(",
")",
"instanceof",
"WsdlDocument",
"&&",
"$",
"... | Adds Wsdl location
@param Wsdl $wsdl
@param string $schemaLocation
@return Generator | [
"Adds",
"Wsdl",
"location"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Generator/Generator.php#L882-L888 | train |
WsdlToPhp/PackageGenerator | src/Container/Model/Struct.php | Struct.addStruct | public function addStruct($structName, $isStruct = true, $structType = '')
{
if (null === (empty($structType) ? $this->get($structName) : $this->getByType($structName, $structType))) {
$model = new Model($this->generator, $structName, $isStruct);
$this->add($model->setInheritance($structType));
}
return $this;
} | php | public function addStruct($structName, $isStruct = true, $structType = '')
{
if (null === (empty($structType) ? $this->get($structName) : $this->getByType($structName, $structType))) {
$model = new Model($this->generator, $structName, $isStruct);
$this->add($model->setInheritance($structType));
}
return $this;
} | [
"public",
"function",
"addStruct",
"(",
"$",
"structName",
",",
"$",
"isStruct",
"=",
"true",
",",
"$",
"structType",
"=",
"''",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"empty",
"(",
"$",
"structType",
")",
"?",
"$",
"this",
"->",
"get",
"(",
"$",... | Adds type to structs
@param string $structName the original struct name
@param bool $isStruct whether the Struct has to be generated or not
@param string $structType the original struct type
@return Struct | [
"Adds",
"type",
"to",
"structs"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Container/Model/Struct.php#L56-L63 | train |
WsdlToPhp/PackageGenerator | src/Container/Model/Struct.php | Struct.addStructWithAttribute | public function addStructWithAttribute($structName, $attributeName, $attributeType)
{
$this->addStruct($structName);
if (($struct = $this->getStructByName($structName)) instanceof Model) {
$struct->addAttribute($attributeName, $attributeType);
}
return $this;
} | php | public function addStructWithAttribute($structName, $attributeName, $attributeType)
{
$this->addStruct($structName);
if (($struct = $this->getStructByName($structName)) instanceof Model) {
$struct->addAttribute($attributeName, $attributeType);
}
return $this;
} | [
"public",
"function",
"addStructWithAttribute",
"(",
"$",
"structName",
",",
"$",
"attributeName",
",",
"$",
"attributeType",
")",
"{",
"$",
"this",
"->",
"addStruct",
"(",
"$",
"structName",
")",
";",
"if",
"(",
"(",
"$",
"struct",
"=",
"$",
"this",
"->... | Adds type to structs and its attribute
@param string $structName the original struct name
@param string $attributeName the attribute name
@param string $attributeType the attribute type
@return Struct | [
"Adds",
"type",
"to",
"structs",
"and",
"its",
"attribute"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Container/Model/Struct.php#L71-L78 | train |
WsdlToPhp/PackageGenerator | src/Container/Model/Struct.php | Struct.addUnionStruct | public function addUnionStruct($structName, $types)
{
$this->addVirtualStruct($structName);
if (($struct = $this->getStructByName($structName)) instanceof Model) {
$struct->setTypes($types);
}
return $this;
} | php | public function addUnionStruct($structName, $types)
{
$this->addVirtualStruct($structName);
if (($struct = $this->getStructByName($structName)) instanceof Model) {
$struct->setTypes($types);
}
return $this;
} | [
"public",
"function",
"addUnionStruct",
"(",
"$",
"structName",
",",
"$",
"types",
")",
"{",
"$",
"this",
"->",
"addVirtualStruct",
"(",
"$",
"structName",
")",
";",
"if",
"(",
"(",
"$",
"struct",
"=",
"$",
"this",
"->",
"getStructByName",
"(",
"$",
"s... | Adds a union struct
@param string $structName
@param string[] $types
@return Struct | [
"Adds",
"a",
"union",
"struct"
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Container/Model/Struct.php#L85-L92 | train |
WsdlToPhp/PackageGenerator | src/Container/Model/Struct.php | Struct.add | public function add($object)
{
$inheritance = $object->getInheritance();
if (!empty($inheritance)) {
$this->virtualObjects[$this->getObjectKeyWithVirtual($object)] = $this->objects[$this->getObjectKeyWithType($object, $object->getInheritance())] = $object;
} else {
parent::add($object);
}
return $this;
} | php | public function add($object)
{
$inheritance = $object->getInheritance();
if (!empty($inheritance)) {
$this->virtualObjects[$this->getObjectKeyWithVirtual($object)] = $this->objects[$this->getObjectKeyWithType($object, $object->getInheritance())] = $object;
} else {
parent::add($object);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"object",
")",
"{",
"$",
"inheritance",
"=",
"$",
"object",
"->",
"getInheritance",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"inheritance",
")",
")",
"{",
"$",
"this",
"->",
"virtualObjects",
"[",
"$",
... | By overriding this method, we ensure that each time a new object is stored, it is stored with our new key if the inheritance is defined.
@param Model $object
@return Struct | [
"By",
"overriding",
"this",
"method",
"we",
"ensure",
"that",
"each",
"time",
"a",
"new",
"object",
"is",
"stored",
"it",
"is",
"stored",
"with",
"our",
"new",
"key",
"if",
"the",
"inheritance",
"is",
"defined",
"."
] | cdd62433018fba5027c39e46c49379af1f95f5e3 | https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/Container/Model/Struct.php#L175-L184 | train |
webmozart/path-util | src/Url.php | Url.makeRelative | public static function makeRelative($url, $baseUrl)
{
Assert::string($url, 'The URL must be a string. Got: %s');
Assert::string($baseUrl, 'The base URL must be a string. Got: %s');
Assert::contains($baseUrl, '://', '%s is not an absolute Url.');
list($baseHost, $basePath) = self::split($baseUrl);
if (false === strpos($url, '://')) {
if (0 === strpos($url, '/')) {
$host = $baseHost;
} else {
$host = '';
}
$path = $url;
} else {
list($host, $path) = self::split($url);
}
if ('' !== $host && $host !== $baseHost) {
throw new InvalidArgumentException(sprintf(
'The URL "%s" cannot be made relative to "%s" since their host names are different.',
$host,
$baseHost
));
}
return Path::makeRelative($path, $basePath);
} | php | public static function makeRelative($url, $baseUrl)
{
Assert::string($url, 'The URL must be a string. Got: %s');
Assert::string($baseUrl, 'The base URL must be a string. Got: %s');
Assert::contains($baseUrl, '://', '%s is not an absolute Url.');
list($baseHost, $basePath) = self::split($baseUrl);
if (false === strpos($url, '://')) {
if (0 === strpos($url, '/')) {
$host = $baseHost;
} else {
$host = '';
}
$path = $url;
} else {
list($host, $path) = self::split($url);
}
if ('' !== $host && $host !== $baseHost) {
throw new InvalidArgumentException(sprintf(
'The URL "%s" cannot be made relative to "%s" since their host names are different.',
$host,
$baseHost
));
}
return Path::makeRelative($path, $basePath);
} | [
"public",
"static",
"function",
"makeRelative",
"(",
"$",
"url",
",",
"$",
"baseUrl",
")",
"{",
"Assert",
"::",
"string",
"(",
"$",
"url",
",",
"'The URL must be a string. Got: %s'",
")",
";",
"Assert",
"::",
"string",
"(",
"$",
"baseUrl",
",",
"'The base UR... | Turns a URL into a relative path.
The result is a canonical path. This class is using functionality of Path class.
@see Path
@param string $url A URL to make relative.
@param string $baseUrl A base URL.
@return string
@throws InvalidArgumentException If the URL and base URL does
not match. | [
"Turns",
"a",
"URL",
"into",
"a",
"relative",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Url.php#L44-L72 | train |
webmozart/path-util | src/Url.php | Url.split | private static function split($url)
{
$pos = strpos($url, '://');
$scheme = substr($url, 0, $pos + 3);
$url = substr($url, $pos + 3);
if (false !== ($pos = strpos($url, '/'))) {
$host = substr($url, 0, $pos);
$url = substr($url, $pos);
} else {
// No path, only host
$host = $url;
$url = '/';
}
// At this point, we have $scheme, $host and $path
$root = $scheme.$host;
return array($root, $url);
} | php | private static function split($url)
{
$pos = strpos($url, '://');
$scheme = substr($url, 0, $pos + 3);
$url = substr($url, $pos + 3);
if (false !== ($pos = strpos($url, '/'))) {
$host = substr($url, 0, $pos);
$url = substr($url, $pos);
} else {
// No path, only host
$host = $url;
$url = '/';
}
// At this point, we have $scheme, $host and $path
$root = $scheme.$host;
return array($root, $url);
} | [
"private",
"static",
"function",
"split",
"(",
"$",
"url",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"url",
",",
"'://'",
")",
";",
"$",
"scheme",
"=",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"$",
"pos",
"+",
"3",
")",
";",
"$",
"url",... | Splits a URL into its host and the path.
```php
list ($root, $path) = Path::split("http://example.com/webmozart")
// => array("http://example.com", "/webmozart")
list ($root, $path) = Path::split("http://example.com")
// => array("http://example.com", "")
```
@param string $url The URL to split.
@return string[] An array with the host and the path of the URL.
@throws InvalidArgumentException If $url is not a URL. | [
"Splits",
"a",
"URL",
"into",
"its",
"host",
"and",
"the",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Url.php#L91-L110 | train |
webmozart/path-util | src/Path.php | Path.getDirectory | public static function getDirectory($path)
{
if ('' === $path) {
return '';
}
$path = static::canonicalize($path);
// Maintain scheme
if (false !== ($pos = strpos($path, '://'))) {
$scheme = substr($path, 0, $pos + 3);
$path = substr($path, $pos + 3);
} else {
$scheme = '';
}
if (false !== ($pos = strrpos($path, '/'))) {
// Directory equals root directory "/"
if (0 === $pos) {
return $scheme.'/';
}
// Directory equals Windows root "C:/"
if (2 === $pos && ctype_alpha($path[0]) && ':' === $path[1]) {
return $scheme.substr($path, 0, 3);
}
return $scheme.substr($path, 0, $pos);
}
return '';
} | php | public static function getDirectory($path)
{
if ('' === $path) {
return '';
}
$path = static::canonicalize($path);
// Maintain scheme
if (false !== ($pos = strpos($path, '://'))) {
$scheme = substr($path, 0, $pos + 3);
$path = substr($path, $pos + 3);
} else {
$scheme = '';
}
if (false !== ($pos = strrpos($path, '/'))) {
// Directory equals root directory "/"
if (0 === $pos) {
return $scheme.'/';
}
// Directory equals Windows root "C:/"
if (2 === $pos && ctype_alpha($path[0]) && ':' === $path[1]) {
return $scheme.substr($path, 0, 3);
}
return $scheme.substr($path, 0, $pos);
}
return '';
} | [
"public",
"static",
"function",
"getDirectory",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"path",
")",
"{",
"return",
"''",
";",
"}",
"$",
"path",
"=",
"static",
"::",
"canonicalize",
"(",
"$",
"path",
")",
";",
"// Maintain scheme",
"... | Returns the directory part of the path.
This method is similar to PHP's dirname(), but handles various cases
where dirname() returns a weird result:
- dirname() does not accept backslashes on UNIX
- dirname("C:/webmozart") returns "C:", not "C:/"
- dirname("C:/") returns ".", not "C:/"
- dirname("C:") returns ".", not "C:/"
- dirname("webmozart") returns ".", not ""
- dirname() does not canonicalize the result
This method fixes these shortcomings and behaves like dirname()
otherwise.
The result is a canonical path.
@param string $path A path string.
@return string The canonical directory part. Returns the root directory
if the root directory is passed. Returns an empty string
if a relative path is passed that contains no slashes.
Returns an empty string if an empty string is passed.
@since 1.0 Added method.
@since 2.0 Method now fails if $path is not a string. | [
"Returns",
"the",
"directory",
"part",
"of",
"the",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L194-L225 | train |
webmozart/path-util | src/Path.php | Path.getHomeDirectory | public static function getHomeDirectory()
{
// For UNIX support
if (getenv('HOME')) {
return static::canonicalize(getenv('HOME'));
}
// For >= Windows8 support
if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
return static::canonicalize(getenv('HOMEDRIVE').getenv('HOMEPATH'));
}
throw new RuntimeException("Your environment or operation system isn't supported");
} | php | public static function getHomeDirectory()
{
// For UNIX support
if (getenv('HOME')) {
return static::canonicalize(getenv('HOME'));
}
// For >= Windows8 support
if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
return static::canonicalize(getenv('HOMEDRIVE').getenv('HOMEPATH'));
}
throw new RuntimeException("Your environment or operation system isn't supported");
} | [
"public",
"static",
"function",
"getHomeDirectory",
"(",
")",
"{",
"// For UNIX support",
"if",
"(",
"getenv",
"(",
"'HOME'",
")",
")",
"{",
"return",
"static",
"::",
"canonicalize",
"(",
"getenv",
"(",
"'HOME'",
")",
")",
";",
"}",
"// For >= Windows8 support... | Returns canonical path of the user's home directory.
Supported operating systems:
- UNIX
- Windows8 and upper
If your operation system or environment isn't supported, an exception is thrown.
The result is a canonical path.
@return string The canonical home directory
@throws RuntimeException If your operation system or environment isn't supported
@since 2.1 Added method. | [
"Returns",
"canonical",
"path",
"of",
"the",
"user",
"s",
"home",
"directory",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L245-L258 | train |
webmozart/path-util | src/Path.php | Path.getRoot | public static function getRoot($path)
{
if ('' === $path) {
return '';
}
Assert::string($path, 'The path must be a string. Got: %s');
// Maintain scheme
if (false !== ($pos = strpos($path, '://'))) {
$scheme = substr($path, 0, $pos + 3);
$path = substr($path, $pos + 3);
} else {
$scheme = '';
}
// UNIX root "/" or "\" (Windows style)
if ('/' === $path[0] || '\\' === $path[0]) {
return $scheme.'/';
}
$length = strlen($path);
// Windows root
if ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
// Special case: "C:"
if (2 === $length) {
return $scheme.$path.'/';
}
// Normal case: "C:/ or "C:\"
if ('/' === $path[2] || '\\' === $path[2]) {
return $scheme.$path[0].$path[1].'/';
}
}
return '';
} | php | public static function getRoot($path)
{
if ('' === $path) {
return '';
}
Assert::string($path, 'The path must be a string. Got: %s');
// Maintain scheme
if (false !== ($pos = strpos($path, '://'))) {
$scheme = substr($path, 0, $pos + 3);
$path = substr($path, $pos + 3);
} else {
$scheme = '';
}
// UNIX root "/" or "\" (Windows style)
if ('/' === $path[0] || '\\' === $path[0]) {
return $scheme.'/';
}
$length = strlen($path);
// Windows root
if ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
// Special case: "C:"
if (2 === $length) {
return $scheme.$path.'/';
}
// Normal case: "C:/ or "C:\"
if ('/' === $path[2] || '\\' === $path[2]) {
return $scheme.$path[0].$path[1].'/';
}
}
return '';
} | [
"public",
"static",
"function",
"getRoot",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"path",
")",
"{",
"return",
"''",
";",
"}",
"Assert",
"::",
"string",
"(",
"$",
"path",
",",
"'The path must be a string. Got: %s'",
")",
";",
"// Maintai... | Returns the root directory of a path.
The result is a canonical path.
@param string $path A path string.
@return string The canonical root directory. Returns an empty string if
the given path is relative or empty.
@since 1.0 Added method.
@since 2.0 Method now fails if $path is not a string. | [
"Returns",
"the",
"root",
"directory",
"of",
"a",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L273-L310 | train |
webmozart/path-util | src/Path.php | Path.getFilenameWithoutExtension | public static function getFilenameWithoutExtension($path, $extension = null)
{
if ('' === $path) {
return '';
}
Assert::string($path, 'The path must be a string. Got: %s');
Assert::nullOrString($extension, 'The extension must be a string or null. Got: %s');
if (null !== $extension) {
// remove extension and trailing dot
return rtrim(basename($path, $extension), '.');
}
return pathinfo($path, PATHINFO_FILENAME);
} | php | public static function getFilenameWithoutExtension($path, $extension = null)
{
if ('' === $path) {
return '';
}
Assert::string($path, 'The path must be a string. Got: %s');
Assert::nullOrString($extension, 'The extension must be a string or null. Got: %s');
if (null !== $extension) {
// remove extension and trailing dot
return rtrim(basename($path, $extension), '.');
}
return pathinfo($path, PATHINFO_FILENAME);
} | [
"public",
"static",
"function",
"getFilenameWithoutExtension",
"(",
"$",
"path",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"path",
")",
"{",
"return",
"''",
";",
"}",
"Assert",
"::",
"string",
"(",
"$",
"path",
",",
"... | Returns the file name without the extension from a file path.
@param string $path The path string.
@param string|null $extension If specified, only that extension is cut
off (may contain leading dot).
@return string The file name without extension.
@since 1.1 Added method.
@since 2.0 Method now fails if $path or $extension have invalid types. | [
"Returns",
"the",
"file",
"name",
"without",
"the",
"extension",
"from",
"a",
"file",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L345-L360 | train |
webmozart/path-util | src/Path.php | Path.getExtension | public static function getExtension($path, $forceLowerCase = false)
{
if ('' === $path) {
return '';
}
Assert::string($path, 'The path must be a string. Got: %s');
$extension = pathinfo($path, PATHINFO_EXTENSION);
if ($forceLowerCase) {
$extension = self::toLower($extension);
}
return $extension;
} | php | public static function getExtension($path, $forceLowerCase = false)
{
if ('' === $path) {
return '';
}
Assert::string($path, 'The path must be a string. Got: %s');
$extension = pathinfo($path, PATHINFO_EXTENSION);
if ($forceLowerCase) {
$extension = self::toLower($extension);
}
return $extension;
} | [
"public",
"static",
"function",
"getExtension",
"(",
"$",
"path",
",",
"$",
"forceLowerCase",
"=",
"false",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"path",
")",
"{",
"return",
"''",
";",
"}",
"Assert",
"::",
"string",
"(",
"$",
"path",
",",
"'The path... | Returns the extension from a file path.
@param string $path The path string.
@param bool $forceLowerCase Forces the extension to be lower-case
(requires mbstring extension for correct
multi-byte character handling in extension).
@return string The extension of the file path (without leading dot).
@since 1.1 Added method.
@since 2.0 Method now fails if $path is not a string. | [
"Returns",
"the",
"extension",
"from",
"a",
"file",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L375-L390 | train |
webmozart/path-util | src/Path.php | Path.isAbsolute | public static function isAbsolute($path)
{
if ('' === $path) {
return false;
}
Assert::string($path, 'The path must be a string. Got: %s');
// Strip scheme
if (false !== ($pos = strpos($path, '://'))) {
$path = substr($path, $pos + 3);
}
// UNIX root "/" or "\" (Windows style)
if ('/' === $path[0] || '\\' === $path[0]) {
return true;
}
// Windows root
if (strlen($path) > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
// Special case: "C:"
if (2 === strlen($path)) {
return true;
}
// Normal case: "C:/ or "C:\"
if ('/' === $path[2] || '\\' === $path[2]) {
return true;
}
}
return false;
} | php | public static function isAbsolute($path)
{
if ('' === $path) {
return false;
}
Assert::string($path, 'The path must be a string. Got: %s');
// Strip scheme
if (false !== ($pos = strpos($path, '://'))) {
$path = substr($path, $pos + 3);
}
// UNIX root "/" or "\" (Windows style)
if ('/' === $path[0] || '\\' === $path[0]) {
return true;
}
// Windows root
if (strlen($path) > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
// Special case: "C:"
if (2 === strlen($path)) {
return true;
}
// Normal case: "C:/ or "C:\"
if ('/' === $path[2] || '\\' === $path[2]) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"isAbsolute",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"path",
")",
"{",
"return",
"false",
";",
"}",
"Assert",
"::",
"string",
"(",
"$",
"path",
",",
"'The path must be a string. Got: %s'",
")",
";",
"// S... | Returns whether a path is absolute.
@param string $path A path string.
@return bool Returns true if the path is absolute, false if it is
relative or empty.
@since 1.0 Added method.
@since 2.0 Method now fails if $path is not a string. | [
"Returns",
"whether",
"a",
"path",
"is",
"absolute",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L487-L519 | train |
webmozart/path-util | src/Path.php | Path.makeAbsolute | public static function makeAbsolute($path, $basePath)
{
Assert::stringNotEmpty($basePath, 'The base path must be a non-empty string. Got: %s');
if (!static::isAbsolute($basePath)) {
throw new InvalidArgumentException(sprintf(
'The base path "%s" is not an absolute path.',
$basePath
));
}
if (static::isAbsolute($path)) {
return static::canonicalize($path);
}
if (false !== ($pos = strpos($basePath, '://'))) {
$scheme = substr($basePath, 0, $pos + 3);
$basePath = substr($basePath, $pos + 3);
} else {
$scheme = '';
}
return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
} | php | public static function makeAbsolute($path, $basePath)
{
Assert::stringNotEmpty($basePath, 'The base path must be a non-empty string. Got: %s');
if (!static::isAbsolute($basePath)) {
throw new InvalidArgumentException(sprintf(
'The base path "%s" is not an absolute path.',
$basePath
));
}
if (static::isAbsolute($path)) {
return static::canonicalize($path);
}
if (false !== ($pos = strpos($basePath, '://'))) {
$scheme = substr($basePath, 0, $pos + 3);
$basePath = substr($basePath, $pos + 3);
} else {
$scheme = '';
}
return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
} | [
"public",
"static",
"function",
"makeAbsolute",
"(",
"$",
"path",
",",
"$",
"basePath",
")",
"{",
"Assert",
"::",
"stringNotEmpty",
"(",
"$",
"basePath",
",",
"'The base path must be a non-empty string. Got: %s'",
")",
";",
"if",
"(",
"!",
"static",
"::",
"isAbs... | Turns a relative path into an absolute path.
Usually, the relative path is appended to the given base path. Dot
segments ("." and "..") are removed/collapsed and all slashes turned
into forward slashes.
```php
echo Path::makeAbsolute("../style.css", "/webmozart/puli/css");
// => /webmozart/puli/style.css
```
If an absolute path is passed, that path is returned unless its root
directory is different than the one of the base path. In that case, an
exception is thrown.
```php
Path::makeAbsolute("/style.css", "/webmozart/puli/css");
// => /style.css
Path::makeAbsolute("C:/style.css", "C:/webmozart/puli/css");
// => C:/style.css
Path::makeAbsolute("C:/style.css", "/webmozart/puli/css");
// InvalidArgumentException
```
If the base path is not an absolute path, an exception is thrown.
The result is a canonical path.
@param string $path A path to make absolute.
@param string $basePath An absolute base path.
@return string An absolute path in canonical form.
@throws InvalidArgumentException If the base path is not absolute or if
the given path is an absolute path with
a different root than the base path.
@since 1.0 Added method.
@since 2.0 Method now fails if $path or $basePath is not a string.
@since 2.2.2 Method does not fail anymore of $path and $basePath are
absolute, but on different partitions. | [
"Turns",
"a",
"relative",
"path",
"into",
"an",
"absolute",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L582-L605 | train |
webmozart/path-util | src/Path.php | Path.makeRelative | public static function makeRelative($path, $basePath)
{
Assert::string($basePath, 'The base path must be a string. Got: %s');
$path = static::canonicalize($path);
$basePath = static::canonicalize($basePath);
list($root, $relativePath) = self::split($path);
list($baseRoot, $relativeBasePath) = self::split($basePath);
// If the base path is given as absolute path and the path is already
// relative, consider it to be relative to the given absolute path
// already
if ('' === $root && '' !== $baseRoot) {
// If base path is already in its root
if ('' === $relativeBasePath) {
$relativePath = ltrim($relativePath, './\\');
}
return $relativePath;
}
// If the passed path is absolute, but the base path is not, we
// cannot generate a relative path
if ('' !== $root && '' === $baseRoot) {
throw new InvalidArgumentException(sprintf(
'The absolute path "%s" cannot be made relative to the '.
'relative path "%s". You should provide an absolute base '.
'path instead.',
$path,
$basePath
));
}
// Fail if the roots of the two paths are different
if ($baseRoot && $root !== $baseRoot) {
throw new InvalidArgumentException(sprintf(
'The path "%s" cannot be made relative to "%s", because they '.
'have different roots ("%s" and "%s").',
$path,
$basePath,
$root,
$baseRoot
));
}
if ('' === $relativeBasePath) {
return $relativePath;
}
// Build a "../../" prefix with as many "../" parts as necessary
$parts = explode('/', $relativePath);
$baseParts = explode('/', $relativeBasePath);
$dotDotPrefix = '';
// Once we found a non-matching part in the prefix, we need to add
// "../" parts for all remaining parts
$match = true;
foreach ($baseParts as $i => $basePart) {
if ($match && isset($parts[$i]) && $basePart === $parts[$i]) {
unset($parts[$i]);
continue;
}
$match = false;
$dotDotPrefix .= '../';
}
return rtrim($dotDotPrefix.implode('/', $parts), '/');
} | php | public static function makeRelative($path, $basePath)
{
Assert::string($basePath, 'The base path must be a string. Got: %s');
$path = static::canonicalize($path);
$basePath = static::canonicalize($basePath);
list($root, $relativePath) = self::split($path);
list($baseRoot, $relativeBasePath) = self::split($basePath);
// If the base path is given as absolute path and the path is already
// relative, consider it to be relative to the given absolute path
// already
if ('' === $root && '' !== $baseRoot) {
// If base path is already in its root
if ('' === $relativeBasePath) {
$relativePath = ltrim($relativePath, './\\');
}
return $relativePath;
}
// If the passed path is absolute, but the base path is not, we
// cannot generate a relative path
if ('' !== $root && '' === $baseRoot) {
throw new InvalidArgumentException(sprintf(
'The absolute path "%s" cannot be made relative to the '.
'relative path "%s". You should provide an absolute base '.
'path instead.',
$path,
$basePath
));
}
// Fail if the roots of the two paths are different
if ($baseRoot && $root !== $baseRoot) {
throw new InvalidArgumentException(sprintf(
'The path "%s" cannot be made relative to "%s", because they '.
'have different roots ("%s" and "%s").',
$path,
$basePath,
$root,
$baseRoot
));
}
if ('' === $relativeBasePath) {
return $relativePath;
}
// Build a "../../" prefix with as many "../" parts as necessary
$parts = explode('/', $relativePath);
$baseParts = explode('/', $relativeBasePath);
$dotDotPrefix = '';
// Once we found a non-matching part in the prefix, we need to add
// "../" parts for all remaining parts
$match = true;
foreach ($baseParts as $i => $basePart) {
if ($match && isset($parts[$i]) && $basePart === $parts[$i]) {
unset($parts[$i]);
continue;
}
$match = false;
$dotDotPrefix .= '../';
}
return rtrim($dotDotPrefix.implode('/', $parts), '/');
} | [
"public",
"static",
"function",
"makeRelative",
"(",
"$",
"path",
",",
"$",
"basePath",
")",
"{",
"Assert",
"::",
"string",
"(",
"$",
"basePath",
",",
"'The base path must be a string. Got: %s'",
")",
";",
"$",
"path",
"=",
"static",
"::",
"canonicalize",
"(",... | Turns a path into a relative path.
The relative path is created relative to the given base path:
```php
echo Path::makeRelative("/webmozart/style.css", "/webmozart/puli");
// => ../style.css
```
If a relative path is passed and the base path is absolute, the relative
path is returned unchanged:
```php
Path::makeRelative("style.css", "/webmozart/puli/css");
// => style.css
```
If both paths are relative, the relative path is created with the
assumption that both paths are relative to the same directory:
```php
Path::makeRelative("style.css", "webmozart/puli/css");
// => ../../../style.css
```
If both paths are absolute, their root directory must be the same,
otherwise an exception is thrown:
```php
Path::makeRelative("C:/webmozart/style.css", "/webmozart/puli");
// InvalidArgumentException
```
If the passed path is absolute, but the base path is not, an exception
is thrown as well:
```php
Path::makeRelative("/webmozart/style.css", "webmozart/puli");
// InvalidArgumentException
```
If the base path is not an absolute path, an exception is thrown.
The result is a canonical path.
@param string $path A path to make relative.
@param string $basePath A base path.
@return string A relative path in canonical form.
@throws InvalidArgumentException If the base path is not absolute or if
the given path has a different root
than the base path.
@since 1.0 Added method.
@since 2.0 Method now fails if $path or $basePath is not a string. | [
"Turns",
"a",
"path",
"into",
"a",
"relative",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L665-L736 | train |
webmozart/path-util | src/Path.php | Path.getLongestCommonBasePath | public static function getLongestCommonBasePath(array $paths)
{
Assert::allString($paths, 'The paths must be strings. Got: %s');
list($bpRoot, $basePath) = self::split(self::canonicalize(reset($paths)));
for (next($paths); null !== key($paths) && '' !== $basePath; next($paths)) {
list($root, $path) = self::split(self::canonicalize(current($paths)));
// If we deal with different roots (e.g. C:/ vs. D:/), it's time
// to quit
if ($root !== $bpRoot) {
return null;
}
// Make the base path shorter until it fits into path
while (true) {
if ('.' === $basePath) {
// No more base paths
$basePath = '';
// Next path
continue 2;
}
// Prevent false positives for common prefixes
// see isBasePath()
if (0 === strpos($path.'/', $basePath.'/')) {
// Next path
continue 2;
}
$basePath = dirname($basePath);
}
}
return $bpRoot.$basePath;
} | php | public static function getLongestCommonBasePath(array $paths)
{
Assert::allString($paths, 'The paths must be strings. Got: %s');
list($bpRoot, $basePath) = self::split(self::canonicalize(reset($paths)));
for (next($paths); null !== key($paths) && '' !== $basePath; next($paths)) {
list($root, $path) = self::split(self::canonicalize(current($paths)));
// If we deal with different roots (e.g. C:/ vs. D:/), it's time
// to quit
if ($root !== $bpRoot) {
return null;
}
// Make the base path shorter until it fits into path
while (true) {
if ('.' === $basePath) {
// No more base paths
$basePath = '';
// Next path
continue 2;
}
// Prevent false positives for common prefixes
// see isBasePath()
if (0 === strpos($path.'/', $basePath.'/')) {
// Next path
continue 2;
}
$basePath = dirname($basePath);
}
}
return $bpRoot.$basePath;
} | [
"public",
"static",
"function",
"getLongestCommonBasePath",
"(",
"array",
"$",
"paths",
")",
"{",
"Assert",
"::",
"allString",
"(",
"$",
"paths",
",",
"'The paths must be strings. Got: %s'",
")",
";",
"list",
"(",
"$",
"bpRoot",
",",
"$",
"basePath",
")",
"=",... | Returns the longest common base path of a set of paths.
Dot segments ("." and "..") are removed/collapsed and all slashes turned
into forward slashes.
```php
$basePath = Path::getLongestCommonBasePath(array(
'/webmozart/css/style.css',
'/webmozart/css/..'
));
// => /webmozart
```
The root is returned if no common base path can be found:
```php
$basePath = Path::getLongestCommonBasePath(array(
'/webmozart/css/style.css',
'/puli/css/..'
));
// => /
```
If the paths are located on different Windows partitions, `null` is
returned.
```php
$basePath = Path::getLongestCommonBasePath(array(
'C:/webmozart/css/style.css',
'D:/webmozart/css/..'
));
// => null
```
@param array $paths A list of paths.
@return string|null The longest common base path in canonical form or
`null` if the paths are on different Windows
partitions.
@since 1.0 Added method.
@since 2.0 Method now fails if $paths are not strings. | [
"Returns",
"the",
"longest",
"common",
"base",
"path",
"of",
"a",
"set",
"of",
"paths",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L799-L836 | train |
webmozart/path-util | src/Path.php | Path.join | public static function join($paths)
{
if (!is_array($paths)) {
$paths = func_get_args();
}
Assert::allString($paths, 'The paths must be strings. Got: %s');
$finalPath = null;
$wasScheme = false;
foreach ($paths as $path) {
$path = (string) $path;
if ('' === $path) {
continue;
}
if (null === $finalPath) {
// For first part we keep slashes, like '/top', 'C:\' or 'phar://'
$finalPath = $path;
$wasScheme = (strpos($path, '://') !== false);
continue;
}
// Only add slash if previous part didn't end with '/' or '\'
if (!in_array(substr($finalPath, -1), array('/', '\\'))) {
$finalPath .= '/';
}
// If first part included a scheme like 'phar://' we allow current part to start with '/', otherwise trim
$finalPath .= $wasScheme ? $path : ltrim($path, '/');
$wasScheme = false;
}
if (null === $finalPath) {
return '';
}
return self::canonicalize($finalPath);
} | php | public static function join($paths)
{
if (!is_array($paths)) {
$paths = func_get_args();
}
Assert::allString($paths, 'The paths must be strings. Got: %s');
$finalPath = null;
$wasScheme = false;
foreach ($paths as $path) {
$path = (string) $path;
if ('' === $path) {
continue;
}
if (null === $finalPath) {
// For first part we keep slashes, like '/top', 'C:\' or 'phar://'
$finalPath = $path;
$wasScheme = (strpos($path, '://') !== false);
continue;
}
// Only add slash if previous part didn't end with '/' or '\'
if (!in_array(substr($finalPath, -1), array('/', '\\'))) {
$finalPath .= '/';
}
// If first part included a scheme like 'phar://' we allow current part to start with '/', otherwise trim
$finalPath .= $wasScheme ? $path : ltrim($path, '/');
$wasScheme = false;
}
if (null === $finalPath) {
return '';
}
return self::canonicalize($finalPath);
} | [
"public",
"static",
"function",
"join",
"(",
"$",
"paths",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"paths",
")",
")",
"{",
"$",
"paths",
"=",
"func_get_args",
"(",
")",
";",
"}",
"Assert",
"::",
"allString",
"(",
"$",
"paths",
",",
"'The pa... | Joins two or more path strings.
The result is a canonical path.
@param string[]|string $paths Path parts as parameters or array.
@return string The joint path.
@since 2.0 Added method. | [
"Joins",
"two",
"or",
"more",
"path",
"strings",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L849-L889 | train |
webmozart/path-util | src/Path.php | Path.isBasePath | public static function isBasePath($basePath, $ofPath)
{
Assert::string($basePath, 'The base path must be a string. Got: %s');
$basePath = self::canonicalize($basePath);
$ofPath = self::canonicalize($ofPath);
// Append slashes to prevent false positives when two paths have
// a common prefix, for example /base/foo and /base/foobar.
// Don't append a slash for the root "/", because then that root
// won't be discovered as common prefix ("//" is not a prefix of
// "/foobar/").
return 0 === strpos($ofPath.'/', rtrim($basePath, '/').'/');
} | php | public static function isBasePath($basePath, $ofPath)
{
Assert::string($basePath, 'The base path must be a string. Got: %s');
$basePath = self::canonicalize($basePath);
$ofPath = self::canonicalize($ofPath);
// Append slashes to prevent false positives when two paths have
// a common prefix, for example /base/foo and /base/foobar.
// Don't append a slash for the root "/", because then that root
// won't be discovered as common prefix ("//" is not a prefix of
// "/foobar/").
return 0 === strpos($ofPath.'/', rtrim($basePath, '/').'/');
} | [
"public",
"static",
"function",
"isBasePath",
"(",
"$",
"basePath",
",",
"$",
"ofPath",
")",
"{",
"Assert",
"::",
"string",
"(",
"$",
"basePath",
",",
"'The base path must be a string. Got: %s'",
")",
";",
"$",
"basePath",
"=",
"self",
"::",
"canonicalize",
"(... | Returns whether a path is a base path of another path.
Dot segments ("." and "..") are removed/collapsed and all slashes turned
into forward slashes.
```php
Path::isBasePath('/webmozart', '/webmozart/css');
// => true
Path::isBasePath('/webmozart', '/webmozart');
// => true
Path::isBasePath('/webmozart', '/webmozart/..');
// => false
Path::isBasePath('/webmozart', '/puli');
// => false
```
@param string $basePath The base path to test.
@param string $ofPath The other path.
@return bool Whether the base path is a base path of the other path.
@since 1.0 Added method.
@since 2.0 Method now fails if $basePath or $ofPath is not a string. | [
"Returns",
"whether",
"a",
"path",
"is",
"a",
"base",
"path",
"of",
"another",
"path",
"."
] | 95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2 | https://github.com/webmozart/path-util/blob/95a8f7ad150c2a3773ff3c3d04f557a24c99cfd2/src/Path.php#L919-L932 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php | TranslationRepository.findAllNotDisabled | public function findAllNotDisabled($locale, $domain = null)
{
$qb = $this->createQueryBuilder('t');
$qb
->select('t')
->where('t.locale = :locale')
->andWhere('t.status != :statusstring')
->setParameter('statusstring', Translation::STATUS_DISABLED)
->setParameter('locale', $locale);
if (!\is_null($domain) && !empty($domain)) {
$qb->andWhere('t.domain = :tdomain')
->setParameter('tdomain', $domain);
}
return $qb->getQuery()->getResult();
} | php | public function findAllNotDisabled($locale, $domain = null)
{
$qb = $this->createQueryBuilder('t');
$qb
->select('t')
->where('t.locale = :locale')
->andWhere('t.status != :statusstring')
->setParameter('statusstring', Translation::STATUS_DISABLED)
->setParameter('locale', $locale);
if (!\is_null($domain) && !empty($domain)) {
$qb->andWhere('t.domain = :tdomain')
->setParameter('tdomain', $domain);
}
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"findAllNotDisabled",
"(",
"$",
"locale",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'t'",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'t'",
")",
"->",
"where",
"(",
... | Get an array of all non disabled translations
@param string $locale
@param string $domain
@return array | [
"Get",
"an",
"array",
"of",
"all",
"non",
"disabled",
"translations"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php#L39-L54 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php | TranslationRepository.removeTranslations | public function removeTranslations($translationId)
{
return $this->createQueryBuilder('t')
->delete()
->where('t.translationId = :translationId')
->setParameter('translationId', $translationId)
->getQuery()
->execute();
} | php | public function removeTranslations($translationId)
{
return $this->createQueryBuilder('t')
->delete()
->where('t.translationId = :translationId')
->setParameter('translationId', $translationId)
->getQuery()
->execute();
} | [
"public",
"function",
"removeTranslations",
"(",
"$",
"translationId",
")",
"{",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'t'",
")",
"->",
"delete",
"(",
")",
"->",
"where",
"(",
"'t.translationId = :translationId'",
")",
"->",
"setParameter",
"(... | Removes all translations with the given translation id
@param string $translationId
@return mixed | [
"Removes",
"all",
"translations",
"with",
"the",
"given",
"translation",
"id"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php#L262-L270 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/VotingBundle/Services/RepositoryResolver.php | RepositoryResolver.getRepositoryForEvent | public function getRepositoryForEvent($event)
{
$repository = null;
if ($event instanceof DownVoteEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\UpDown\DownVote');
}
if ($event instanceof UpVoteEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\UpDown\UpVote');
}
if ($event instanceof LinkedInShareEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\LinkedIn\LinkedInShare');
}
if ($event instanceof FacebookLikeEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\Facebook\FacebookLike');
}
if ($event instanceof FacebookSendEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\Facebook\FacebookSend');
}
return $repository;
} | php | public function getRepositoryForEvent($event)
{
$repository = null;
if ($event instanceof DownVoteEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\UpDown\DownVote');
}
if ($event instanceof UpVoteEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\UpDown\UpVote');
}
if ($event instanceof LinkedInShareEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\LinkedIn\LinkedInShare');
}
if ($event instanceof FacebookLikeEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\Facebook\FacebookLike');
}
if ($event instanceof FacebookSendEvent) {
$repository = $this->getRepository('Kunstmaan\VotingBundle\Entity\Facebook\FacebookSend');
}
return $repository;
} | [
"public",
"function",
"getRepositoryForEvent",
"(",
"$",
"event",
")",
"{",
"$",
"repository",
"=",
"null",
";",
"if",
"(",
"$",
"event",
"instanceof",
"DownVoteEvent",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"getRepository",
"(",
"'Kunstmaan\\V... | Return repository for event
@param Event $event event
@return Repository | [
"Return",
"repository",
"for",
"event"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/VotingBundle/Services/RepositoryResolver.php#L39-L64 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsDataCollectCommand.php | GoogleAnalyticsDataCollectCommand.getSingleOverview | private function getSingleOverview($overviewId)
{
// get specified overview
$overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
$overview = $overviewRepository->find($overviewId);
if (!$overview) {
throw new \Exception('Unkown overview ID');
}
return $overview;
} | php | private function getSingleOverview($overviewId)
{
// get specified overview
$overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
$overview = $overviewRepository->find($overviewId);
if (!$overview) {
throw new \Exception('Unkown overview ID');
}
return $overview;
} | [
"private",
"function",
"getSingleOverview",
"(",
"$",
"overviewId",
")",
"{",
"// get specified overview",
"$",
"overviewRepository",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'KunstmaanDashboardBundle:AnalyticsOverview'",
")",
";",
"$",
"overview",
"... | get a single overview
@param int $overviewId
@return AnalyticsOverview | [
"get",
"a",
"single",
"overview"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsDataCollectCommand.php#L155-L166 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsDataCollectCommand.php | GoogleAnalyticsDataCollectCommand.updateData | public function updateData($overviews)
{
// helpers
$queryHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.query');
$configHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.config');
$metrics = new MetricsCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
$chartData = new ChartDataCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
$goals = new GoalCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
$visitors = new UsersCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
// get data per overview
foreach ($overviews as $overview) {
$configHelper->init($overview->getConfig()->getId());
/* @var AnalyticsOverview $overview */
$this->output->writeln('Fetching data for overview "<fg=green>' . $overview->getTitle() . '</fg=green>"');
try {
// metric data
$metrics->getData($overview);
if ($overview->getSessions()) { // if there are any visits
// day-specific data
$chartData->getData($overview);
// get goals
$goals->getData($overview);
// visitor types
$visitors->getData($overview);
} else {
// reset overview
$this->reset($overview);
$this->output->writeln("\t" . 'No visitors');
}
// persist entity back to DB
$this->output->writeln("\t" . 'Persisting..');
$this->em->persist($overview);
$this->em->flush($overview);
$this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->setUpdated($overview->getConfig()->getId());
} catch (\Google_ServiceException $e) {
$error = explode(')', $e->getMessage());
$error = $error[1];
$this->output->writeln("\t" . '<fg=red>Invalid segment: </fg=red>' .$error);
$this->errors += 1;
}
}
} | php | public function updateData($overviews)
{
// helpers
$queryHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.query');
$configHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.config');
$metrics = new MetricsCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
$chartData = new ChartDataCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
$goals = new GoalCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
$visitors = new UsersCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
// get data per overview
foreach ($overviews as $overview) {
$configHelper->init($overview->getConfig()->getId());
/* @var AnalyticsOverview $overview */
$this->output->writeln('Fetching data for overview "<fg=green>' . $overview->getTitle() . '</fg=green>"');
try {
// metric data
$metrics->getData($overview);
if ($overview->getSessions()) { // if there are any visits
// day-specific data
$chartData->getData($overview);
// get goals
$goals->getData($overview);
// visitor types
$visitors->getData($overview);
} else {
// reset overview
$this->reset($overview);
$this->output->writeln("\t" . 'No visitors');
}
// persist entity back to DB
$this->output->writeln("\t" . 'Persisting..');
$this->em->persist($overview);
$this->em->flush($overview);
$this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->setUpdated($overview->getConfig()->getId());
} catch (\Google_ServiceException $e) {
$error = explode(')', $e->getMessage());
$error = $error[1];
$this->output->writeln("\t" . '<fg=red>Invalid segment: </fg=red>' .$error);
$this->errors += 1;
}
}
} | [
"public",
"function",
"updateData",
"(",
"$",
"overviews",
")",
"{",
"// helpers",
"$",
"queryHelper",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'kunstmaan_dashboard.helper.google.analytics.query'",
")",
";",
"$",
"configHelper",
"=",
... | update the overviews
@param array $overviews collection of all overviews which need to be updated | [
"update",
"the",
"overviews"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsDataCollectCommand.php#L260-L306 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/NodeMenu.php | NodeMenu.init | private function init()
{
if ($this->initialized) {
return;
}
$this->allNodes = array();
$this->breadCrumb = null;
$this->childNodes = array();
$this->topNodeMenuItems = null;
$this->nodesByInternalName = array();
/* @var NodeRepository $repo */
$repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
// Get all possible menu items in one query (also fetch offline nodes)
$nodes = $repo->getChildNodes(
false,
$this->locale,
$this->permission,
$this->aclHelper,
$this->includeHiddenFromNav,
true,
$this->domainConfiguration->getRootNode()
);
foreach ($nodes as $node) {
$this->allNodes[$node->getId()] = $node;
if ($node->getParent()) {
$this->childNodes[$node->getParent()->getId()][] = $node;
} else {
$this->childNodes[0][] = $node;
}
$internalName = $node->getInternalName();
if ($internalName) {
$this->nodesByInternalName[$internalName][] = $node;
}
}
$this->initialized = true;
} | php | private function init()
{
if ($this->initialized) {
return;
}
$this->allNodes = array();
$this->breadCrumb = null;
$this->childNodes = array();
$this->topNodeMenuItems = null;
$this->nodesByInternalName = array();
/* @var NodeRepository $repo */
$repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
// Get all possible menu items in one query (also fetch offline nodes)
$nodes = $repo->getChildNodes(
false,
$this->locale,
$this->permission,
$this->aclHelper,
$this->includeHiddenFromNav,
true,
$this->domainConfiguration->getRootNode()
);
foreach ($nodes as $node) {
$this->allNodes[$node->getId()] = $node;
if ($node->getParent()) {
$this->childNodes[$node->getParent()->getId()][] = $node;
} else {
$this->childNodes[0][] = $node;
}
$internalName = $node->getInternalName();
if ($internalName) {
$this->nodesByInternalName[$internalName][] = $node;
}
}
$this->initialized = true;
} | [
"private",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"allNodes",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"breadCrumb",
"=",
"null",
";",
"$",
"this",
"... | This method initializes the nodemenu only once, the method may be
executed multiple times | [
"This",
"method",
"initializes",
"the",
"nodemenu",
"only",
"once",
"the",
"method",
"may",
"be",
"executed",
"multiple",
"times"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php#L167-L206 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/NodeMenu.php | NodeMenu.getRootNodeMenuItem | public function getRootNodeMenuItem()
{
if (is_null($this->rootNodeMenuItem)) {
$rootNode = $this->domainConfiguration->getRootNode();
if (!is_null($rootNode)) {
$nodeTranslation = $rootNode->getNodeTranslation(
$this->locale,
$this->includeOffline
);
$this->rootNodeMenuItem = new NodeMenuItem(
$rootNode,
$nodeTranslation,
false,
$this
);
} else {
$this->rootNodeMenuItem = $this->breadCrumb[0];
}
}
return $this->rootNodeMenuItem;
} | php | public function getRootNodeMenuItem()
{
if (is_null($this->rootNodeMenuItem)) {
$rootNode = $this->domainConfiguration->getRootNode();
if (!is_null($rootNode)) {
$nodeTranslation = $rootNode->getNodeTranslation(
$this->locale,
$this->includeOffline
);
$this->rootNodeMenuItem = new NodeMenuItem(
$rootNode,
$nodeTranslation,
false,
$this
);
} else {
$this->rootNodeMenuItem = $this->breadCrumb[0];
}
}
return $this->rootNodeMenuItem;
} | [
"public",
"function",
"getRootNodeMenuItem",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"rootNodeMenuItem",
")",
")",
"{",
"$",
"rootNode",
"=",
"$",
"this",
"->",
"domainConfiguration",
"->",
"getRootNode",
"(",
")",
";",
"if",
"(",
"!... | Returns the current root node menu item | [
"Returns",
"the",
"current",
"root",
"node",
"menu",
"item"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php#L560-L581 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/NodeMenu.php | NodeMenu.getActive | public function getActive($slug)
{
$bc = $this->getBreadCrumb();
foreach ($bc as $bcItem) {
if ($bcItem->getSlug() == $slug) {
return true;
}
}
return false;
} | php | public function getActive($slug)
{
$bc = $this->getBreadCrumb();
foreach ($bc as $bcItem) {
if ($bcItem->getSlug() == $slug) {
return true;
}
}
return false;
} | [
"public",
"function",
"getActive",
"(",
"$",
"slug",
")",
"{",
"$",
"bc",
"=",
"$",
"this",
"->",
"getBreadCrumb",
"(",
")",
";",
"foreach",
"(",
"$",
"bc",
"as",
"$",
"bcItem",
")",
"{",
"if",
"(",
"$",
"bcItem",
"->",
"getSlug",
"(",
")",
"==",... | Check if provided slug is in active path
@param string $slug
@return bool | [
"Check",
"if",
"provided",
"slug",
"is",
"in",
"active",
"path"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php#L654-L664 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php | GroupPropertiesTrait.getRole | public function getRole($role = null)
{
/* @var $roleItem RoleInterface */
foreach ($this->roles as $roleItem) {
if ($role == $roleItem->getRole()) {
return $roleItem;
}
}
return null;
} | php | public function getRole($role = null)
{
/* @var $roleItem RoleInterface */
foreach ($this->roles as $roleItem) {
if ($role == $roleItem->getRole()) {
return $roleItem;
}
}
return null;
} | [
"public",
"function",
"getRole",
"(",
"$",
"role",
"=",
"null",
")",
"{",
"/* @var $roleItem RoleInterface */",
"foreach",
"(",
"$",
"this",
"->",
"roles",
"as",
"$",
"roleItem",
")",
"{",
"if",
"(",
"$",
"role",
"==",
"$",
"roleItem",
"->",
"getRole",
"... | Pass a string, get the desired Role object or null.
@param string $role
@return Role|null | [
"Pass",
"a",
"string",
"get",
"the",
"desired",
"Role",
"object",
"or",
"null",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php#L106-L116 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php | GroupPropertiesTrait.addRole | public function addRole($role)
{
if (!$role instanceof Role) {
throw new InvalidArgumentException('addRole takes a Role object as the parameter');
}
if (!$this->hasRole($role->getRole())) {
$this->roles->add($role);
}
return $this;
} | php | public function addRole($role)
{
if (!$role instanceof Role) {
throw new InvalidArgumentException('addRole takes a Role object as the parameter');
}
if (!$this->hasRole($role->getRole())) {
$this->roles->add($role);
}
return $this;
} | [
"public",
"function",
"addRole",
"(",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"$",
"role",
"instanceof",
"Role",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'addRole takes a Role object as the parameter'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"... | Adds a Role object to the ArrayCollection. Can't type hint due to interface so throws Exception.
@param Role $role
@return GroupInterface
@throws InvalidArgumentException | [
"Adds",
"a",
"Role",
"object",
"to",
"the",
"ArrayCollection",
".",
"Can",
"t",
"type",
"hint",
"due",
"to",
"interface",
"so",
"throws",
"Exception",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php#L143-L154 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php | GroupPropertiesTrait.removeRole | public function removeRole($role)
{
$roleElement = $this->getRole($role);
if ($roleElement) {
$this->roles->removeElement($roleElement);
}
return $this;
} | php | public function removeRole($role)
{
$roleElement = $this->getRole($role);
if ($roleElement) {
$this->roles->removeElement($roleElement);
}
return $this;
} | [
"public",
"function",
"removeRole",
"(",
"$",
"role",
")",
"{",
"$",
"roleElement",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"role",
")",
";",
"if",
"(",
"$",
"roleElement",
")",
"{",
"$",
"this",
"->",
"roles",
"->",
"removeElement",
"(",
"$",
... | Pass a string, remove the Role object from collection.
@param string $role
@return GroupInterface | [
"Pass",
"a",
"string",
"remove",
"the",
"Role",
"object",
"from",
"collection",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php#L163-L171 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php | GroupPropertiesTrait.setRoles | public function setRoles(array $roles)
{
$this->roles->clear();
foreach ($roles as $role) {
$this->addRole($role);
}
return $this;
} | php | public function setRoles(array $roles)
{
$this->roles->clear();
foreach ($roles as $role) {
$this->addRole($role);
}
return $this;
} | [
"public",
"function",
"setRoles",
"(",
"array",
"$",
"roles",
")",
"{",
"$",
"this",
"->",
"roles",
"->",
"clear",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"addRole",
"(",
"$",
"role",
")",
";",... | Pass an ARRAY of Role objects and will clear the collection and re-set it with new Roles.
@param Role[] $roles array of Role objects
@return GroupInterface | [
"Pass",
"an",
"ARRAY",
"of",
"Role",
"objects",
"and",
"will",
"clear",
"the",
"collection",
"and",
"re",
"-",
"set",
"it",
"with",
"new",
"Roles",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php#L180-L188 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.findFirst | public function findFirst($createNew = true)
{
// Backwards compatibility: select the first config, still used in the dashboard, specified config ids are set in the dashboard collection bundle
$em = $this->getEntityManager();
$query = $em->createQuery('SELECT c FROM KunstmaanDashboardBundle:AnalyticsConfig c');
$result = $query->getResult();
// if no configs exist, create a new one
if (!$result && $createNew) {
return $this->createConfig();
} elseif ($result) {
return $result[0];
} else {
return false;
}
} | php | public function findFirst($createNew = true)
{
// Backwards compatibility: select the first config, still used in the dashboard, specified config ids are set in the dashboard collection bundle
$em = $this->getEntityManager();
$query = $em->createQuery('SELECT c FROM KunstmaanDashboardBundle:AnalyticsConfig c');
$result = $query->getResult();
// if no configs exist, create a new one
if (!$result && $createNew) {
return $this->createConfig();
} elseif ($result) {
return $result[0];
} else {
return false;
}
} | [
"public",
"function",
"findFirst",
"(",
"$",
"createNew",
"=",
"true",
")",
"{",
"// Backwards compatibility: select the first config, still used in the dashboard, specified config ids are set in the dashboard collection bundle",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager... | Get the first config from the database, creates a new entry if the config doesn't exist yet
@return AnalyticsConfig $config | [
"Get",
"the",
"first",
"config",
"from",
"the",
"database",
"creates",
"a",
"new",
"entry",
"if",
"the",
"config",
"doesn",
"t",
"exist",
"yet"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L21-L35 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.findDefaultOverviews | public function findDefaultOverviews($config)
{
$em = $this->getEntityManager();
return $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')
->findBy(array(
'config' => $config,
'segment' => null,
));
} | php | public function findDefaultOverviews($config)
{
$em = $this->getEntityManager();
return $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')
->findBy(array(
'config' => $config,
'segment' => null,
));
} | [
"public",
"function",
"findDefaultOverviews",
"(",
"$",
"config",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"return",
"$",
"em",
"->",
"getRepository",
"(",
"'KunstmaanDashboardBundle:AnalyticsOverview'",
")",
"->",
"findBy"... | Get the default overviews for a config
@return AnalyticsConfig $config | [
"Get",
"the",
"default",
"overviews",
"for",
"a",
"config"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L42-L51 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.createConfig | public function createConfig()
{
$em = $this->getEntityManager();
$config = new AnalyticsConfig();
$em->persist($config);
$em->flush();
$this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')->addOverviews($config);
return $config;
} | php | public function createConfig()
{
$em = $this->getEntityManager();
$config = new AnalyticsConfig();
$em->persist($config);
$em->flush();
$this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')->addOverviews($config);
return $config;
} | [
"public",
"function",
"createConfig",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"new",
"AnalyticsConfig",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"config",
")",
";",
"$",
"... | Create a new config
@return AnalyticsConfig | [
"Create",
"a",
"new",
"config"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L58-L69 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.flushConfig | public function flushConfig($id = false)
{
$em = $this->getEntityManager();
// Backward compatibilty to flush overviews without a config set
if (!$id) {
$overviewRepository = $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
foreach ($overviewRepository->findAll() as $overview) {
$em->remove($overview);
}
$em->flush();
return;
}
$config = $id ? $this->find($id) : $this->findFirst();
foreach ($config->getOverviews() as $overview) {
$em->remove($overview);
}
foreach ($config->getSegments() as $segment) {
$em->remove($segment);
}
$em->flush();
} | php | public function flushConfig($id = false)
{
$em = $this->getEntityManager();
// Backward compatibilty to flush overviews without a config set
if (!$id) {
$overviewRepository = $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
foreach ($overviewRepository->findAll() as $overview) {
$em->remove($overview);
}
$em->flush();
return;
}
$config = $id ? $this->find($id) : $this->findFirst();
foreach ($config->getOverviews() as $overview) {
$em->remove($overview);
}
foreach ($config->getSegments() as $segment) {
$em->remove($segment);
}
$em->flush();
} | [
"public",
"function",
"flushConfig",
"(",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"// Backward compatibilty to flush overviews without a config set",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"... | Flush a config
@param int $id the config id | [
"Flush",
"a",
"config"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L76-L99 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.setUpdated | public function setUpdated($id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setLastUpdate(new \DateTime());
$em->persist($config);
$em->flush();
} | php | public function setUpdated($id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setLastUpdate(new \DateTime());
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"setUpdated",
"(",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"id",
")",
":",
"$",
"thi... | Update the timestamp when data is collected
@param int id | [
"Update",
"the",
"timestamp",
"when",
"data",
"is",
"collected"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L106-L113 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.saveToken | public function saveToken($token, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setToken($token);
$em->persist($config);
$em->flush();
} | php | public function saveToken($token, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setToken($token);
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"saveToken",
"(",
"$",
"token",
",",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"id",
"... | saves the token
@param string $token | [
"saves",
"the",
"token"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L120-L127 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.savePropertyId | public function savePropertyId($propertyId, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setPropertyId($propertyId);
$em->persist($config);
$em->flush();
} | php | public function savePropertyId($propertyId, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setPropertyId($propertyId);
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"savePropertyId",
"(",
"$",
"propertyId",
",",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
... | saves the property id
@param string $propertyId | [
"saves",
"the",
"property",
"id"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L134-L141 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.saveAccountId | public function saveAccountId($accountId, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setAccountId($accountId);
$em->persist($config);
$em->flush();
} | php | public function saveAccountId($accountId, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setAccountId($accountId);
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"saveAccountId",
"(",
"$",
"accountId",
",",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"... | saves the account id
@param string $accountId | [
"saves",
"the",
"account",
"id"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L148-L155 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.saveProfileId | public function saveProfileId($profileId, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setProfileId($profileId);
$em->persist($config);
$em->flush();
} | php | public function saveProfileId($profileId, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setProfileId($profileId);
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"saveProfileId",
"(",
"$",
"profileId",
",",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"... | saves the profile id
@param string $profileId | [
"saves",
"the",
"profile",
"id"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L162-L169 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.saveConfigName | public function saveConfigName($name, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setName($name);
$em->persist($config);
$em->flush();
} | php | public function saveConfigName($name, $id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setName($name);
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"saveConfigName",
"(",
"$",
"name",
",",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"id",... | saves the config name
@param string $profileId | [
"saves",
"the",
"config",
"name"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L176-L183 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.resetProfileId | public function resetProfileId($id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setProfileId('');
$em->persist($config);
$em->flush();
} | php | public function resetProfileId($id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setProfileId('');
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"resetProfileId",
"(",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"id",
")",
":",
"$",
... | Resets the profile id
@param int id | [
"Resets",
"the",
"profile",
"id"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L190-L197 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php | AnalyticsConfigRepository.resetPropertyId | public function resetPropertyId($id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setAccountId('');
$config->setProfileId('');
$config->setPropertyId('');
$em->persist($config);
$em->flush();
} | php | public function resetPropertyId($id = false)
{
$em = $this->getEntityManager();
$config = $id ? $this->find($id) : $this->findFirst();
$config->setAccountId('');
$config->setProfileId('');
$config->setPropertyId('');
$em->persist($config);
$em->flush();
} | [
"public",
"function",
"resetPropertyId",
"(",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"id",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"id",
")",
":",
"$",
... | Resets the account id, property id and profile id
@param int id | [
"Resets",
"the",
"account",
"id",
"property",
"id",
"and",
"profile",
"id"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsConfigRepository.php#L204-L213 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/Menu/SimpleTreeView.php | SimpleTreeView.addItem | public function addItem($parentId, $data)
{
if (empty($parentId)) {
$this->items[0][] = $data;
} else {
$this->items[$parentId][] = $data;
}
} | php | public function addItem($parentId, $data)
{
if (empty($parentId)) {
$this->items[0][] = $data;
} else {
$this->items[$parentId][] = $data;
}
} | [
"public",
"function",
"addItem",
"(",
"$",
"parentId",
",",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"parentId",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"0",
"]",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"th... | Add an item to the tree array
@param int $parentId
@param array|object $data | [
"Add",
"an",
"item",
"to",
"the",
"tree",
"array"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/Menu/SimpleTreeView.php#L21-L28 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/Twig/AdminListTwigExtension.php | AdminListTwigExtension.renderWidget | public function renderWidget(Twig_Environment $env, AdminList $view, $basepath, array $urlparams = [], array $addparams = [])
{
$filterBuilder = $view->getFilterBuilder();
return $env->render(
'KunstmaanAdminListBundle:AdminListTwigExtension:widget.html.twig',
[
'filter' => $filterBuilder,
'basepath' => $basepath,
'addparams' => $addparams,
'extraparams' => $urlparams,
'adminlist' => $view,
]
);
} | php | public function renderWidget(Twig_Environment $env, AdminList $view, $basepath, array $urlparams = [], array $addparams = [])
{
$filterBuilder = $view->getFilterBuilder();
return $env->render(
'KunstmaanAdminListBundle:AdminListTwigExtension:widget.html.twig',
[
'filter' => $filterBuilder,
'basepath' => $basepath,
'addparams' => $addparams,
'extraparams' => $urlparams,
'adminlist' => $view,
]
);
} | [
"public",
"function",
"renderWidget",
"(",
"Twig_Environment",
"$",
"env",
",",
"AdminList",
"$",
"view",
",",
"$",
"basepath",
",",
"array",
"$",
"urlparams",
"=",
"[",
"]",
",",
"array",
"$",
"addparams",
"=",
"[",
"]",
")",
"{",
"$",
"filterBuilder",
... | Renders the HTML for a given view
Example usage in Twig:
{{ form_widget(view) }}
You can pass options during the call:
{{ form_widget(view, {'attr': {'class': 'foo'}}) }}
{{ form_widget(view, {'separator': '+++++'}) }}
@param Twig_Environment $env
@param AdminList $view The view to render
@param string $basepath The base path
@param array $urlparams Additional url params
@param array $addparams Add params
@return string The html markup
@throws \Throwable
@throws \Twig_Error_Loader
@throws \Twig_Error_Runtime
@throws \Twig_Error_Syntax | [
"Renders",
"the",
"HTML",
"for",
"a",
"given",
"view"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Twig/AdminListTwigExtension.php#L77-L91 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TaggingBundle/EventListener/TagsListener.php | TagsListener.postPersist | public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Taggable) {
$this->getTagManager()->saveTagging($entity);
}
} | php | public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Taggable) {
$this->getTagManager()->saveTagging($entity);
}
} | [
"public",
"function",
"postPersist",
"(",
"LifecycleEventArgs",
"$",
"args",
")",
"{",
"$",
"entity",
"=",
"$",
"args",
"->",
"getEntity",
"(",
")",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"Taggable",
")",
"{",
"$",
"this",
"->",
"getTagManager",
"(... | Runs the postPersist doctrine event and updates the current flag if needed
@param \Doctrine\ORM\Event\LifecycleEventArgs $args | [
"Runs",
"the",
"postPersist",
"doctrine",
"event",
"and",
"updates",
"the",
"current",
"flag",
"if",
"needed"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TaggingBundle/EventListener/TagsListener.php#L51-L58 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.