/** * Wrapper for creating a support group. * It will check if the support group doesn't exist yet, if the tag or name already exists then NAME_TAKEN or TAG_TAKEN will be returned. * If the name is bigger than 20 characters or smaller than 4 and the tag greater than 7 or smaller than 2 a SIZE_ERROR will be returned. * Else it will return SUCCESS * @return a string that specifies if it was a success or not (SUCCESS, SIZE_ERROR, NAME_TAKEN or TAG_TAKEN ) */ public static function createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password) { //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); if (strlen($name) <= 21 && strlen($name) >= 4 && strlen($tag) <= 8 && strlen($tag) >= 2) { $notExists = self::supportGroup_EntryNotExists($name, $tag); //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); if ($notExists == "SUCCESS") { $sGroup = new self(); $values = array('Name' => $name, 'Tag' => $tag, 'GroupEmail' => $groupemail, 'IMAP_MailServer' => $imap_mailserver, 'IMAP_Username' => $imap_username, 'IMAP_Password' => $imap_password); $sGroup->setName($values['Name']); $sGroup->setTag($values['Tag']); $sGroup->setGroupEmail($values['GroupEmail']); $sGroup->setIMAP_MailServer($values['IMAP_MailServer']); $sGroup->setIMAP_Username($values['IMAP_Username']); //encrypt password! global $cfg; $crypter = new MyCrypt($cfg['crypt']); $enc_password = $crypter->encrypt($values['IMAP_Password']); $sGroup->setIMAP_Password($enc_password); $sGroup->create(); //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); } else { //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); //return NAME_TAKEN or TAG_TAKEN return $notExists; } } else { //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); //RETURN ERROR that indicates SIZE return "SIZE_ERROR"; } }
public static function minify($content, $minifier, $options = array()) { $inline = new self(); $inline->setTag('style'); $inline->setMinifier($minifier); $inline->setMinifierOptions($options); $content = $inline->doMinify($content); return $content; }
/** * fromReflection() - Build a docblock generator object from a reflection object * * @param ReflectionDocblock $reflectionDocblock * @return DocblockGenerator */ public static function fromReflection(DocBlockReflection $reflectionDocblock) { $docblock = new self(); $docblock->setSourceContent($reflectionDocblock->getContents()); $docblock->setSourceDirty(false); $docblock->setShortDescription($reflectionDocblock->getShortDescription()); $docblock->setLongDescription($reflectionDocblock->getLongDescription()); foreach ($reflectionDocblock->getTags() as $tag) { $docblock->setTag(Docblock\Tag::fromReflection($tag)); } return $docblock; }
/** * fromReflection() - Build a docblock generator object from a reflection object * * @param Zend_Reflection_Docblock $reflectionDocblock * @return Zend_CodeGenerator_Php_Docblock */ public static function fromReflection(Zend_Reflection_Docblock $reflectionDocblock) { $docblock = new self(); $docblock->setSourceContent($reflectionDocblock->getContents()); $docblock->setSourceDirty(false); $docblock->setShortDescription($reflectionDocblock->getShortDescription()); $docblock->setLongDescription($reflectionDocblock->getLongDescription()); foreach ($reflectionDocblock->getTags() as $tag) { $docblock->setTag(Zend_CodeGenerator_Php_Docblock_Tag::fromReflection($tag)); } return $docblock; }
/** * @param Address $address * @param BlockCypherAddressBalance $blockCypherAddressBalance * @param string $apiUrl * @param string $explorerUrl * @return $this */ public static function from(Address $address, BlockCypherAddressBalance $blockCypherAddressBalance, $apiUrl, $explorerUrl) { $addressListItemDto = new self(); $addressListItemDto->setAddress($address->getAddress()); $addressListItemDto->setTag($address->getTag()); $addressListItemDto->setCreationTime($address->getCreationTime()); $addressListItemDto->setFinalBalance($blockCypherAddressBalance->getFinalBalance()); $addressListItemDto->setNTx($blockCypherAddressBalance->getNTx()); $addressListItemDto->setApiUrl($apiUrl); $addressListItemDto->setExplorerUrl($explorerUrl); return $addressListItemDto; }
/** * Extracts a new response from a communicator. * * @param Communicator $com The communicator from which to extract * the new response. * @param bool $asStream Whether to populate the argument values * with streams instead of strings. * @param int $sTimeout If a response is not immediatly * available, wait this many seconds. If NULL, wait indefinetly. * @param int $usTimeout Microseconds to add to the waiting time. * @param Registry $reg An optional registry to sync the * response with. * * @see getType() * @see getArgument() */ public function __construct(Communicator $com, $asStream = false, $sTimeout = 0, $usTimeout = null, Registry $reg = null) { if (null === $reg) { if ($com->getTransmitter()->isPersistent()) { $old = $com->getTransmitter()->lock(T\Stream::DIRECTION_RECEIVE); try { $this->_receive($com, $asStream, $sTimeout, $usTimeout); } catch (E $e) { $com->getTransmitter()->lock($old, true); throw $e; } $com->getTransmitter()->lock($old, true); } else { $this->_receive($com, $asStream, $sTimeout, $usTimeout); } } else { while (null === ($response = $reg->getNextResponse())) { $newResponse = new self($com, true, $sTimeout, $usTimeout); $tagInfo = $reg::parseTag($newResponse->getTag()); $newResponse->setTag($tagInfo[1]); if (!$reg->add($newResponse, $tagInfo[0])) { $response = $newResponse; break; } } $this->_type = $response->_type; $this->attributes = $response->attributes; $this->unrecognizedWords = $response->unrecognizedWords; $this->setTag($response->getTag()); if (!$asStream) { foreach ($this->attributes as $name => $value) { $this->setAttribute($name, stream_get_contents($value)); } foreach ($response->unrecognizedWords as $i => $value) { $this->unrecognizedWords[$i] = stream_get_contents($value); } } } }
/** * Static method to parse a docblock string and return a new * docblock generator object. * * @param string $docblock * @param string $forceIndent * @throws Exception * @return DocblockGenerator */ public static function parse($docblock, $forceIndent = null) { if (strpos($docblock, '/*') === false || strpos($docblock, '*/') === false) { throw new Exception('The docblock is not in the correct format.'); } $desc = null; $formattedDesc = null; $indent = null; $tags = null; // Parse the description, if any if (strpos($docblock, '@') !== false) { $desc = substr($docblock, 0, strpos($docblock, '@')); $desc = str_replace('/*', '', $desc); $desc = str_replace('*/', '', $desc); $desc = str_replace(PHP_EOL . ' * ', ' ', $desc); $desc = trim(str_replace('*', '', $desc)); $descAry = explode("\n", $desc); $formattedDesc = null; foreach ($descAry as $line) { $formattedDesc .= ' ' . trim($line); } $formattedDesc = trim($formattedDesc); } // Get the indentation, if any, and create docblock object $indent = null === $forceIndent ? substr($docblock, 0, strpos($docblock, '/')) : $forceIndent; $newDocblock = new self($formattedDesc, $indent); // Get the tags, if any if (strpos($docblock, '@') !== false) { $tags = substr($docblock, strpos($docblock, '@')); $tags = substr($tags, 0, strpos($tags, '*/')); $tags = str_replace('*', '', $tags); $tagsAry = explode("\n", $tags); foreach ($tagsAry as $key => $value) { $value = trim(str_replace('@', '', $value)); // Param tags if (stripos($value, 'param') !== false) { $paramtag = trim(str_replace('param', '', $value)); $paramtype = trim(substr($paramtag, 0, strpos($paramtag, ' '))); $varname = null; $paramdesc = null; if (strpos($paramtag, ' ') !== false) { $varname = trim(substr($paramtag, strpos($paramtag, ' '))); if (strpos($varname, ' ') !== false) { $paramdesc = trim(substr($varname, strpos($varname, ' '))); } } else { $paramtype = $paramtag; } $newDocblock->setParam($paramtype, $varname, $paramdesc); // Else, return tags } else { if (stripos($value, 'return') !== false) { $returntag = trim(str_replace('return', '', $value)); if (strpos($returntag, ' ') !== false) { $returntype = substr($returntag, 0, strpos($returntag, ' ')); $returndesc = trim(str_replace($returntype, '', $returntag)); } else { $returntype = $returntag; $returndesc = null; } $newDocblock->setReturn($returntype, $returndesc); // Else, all other tags } else { $tagname = trim(substr($value, 0, strpos($value, ' '))); $tagdesc = trim(str_replace($tagname, '', $value)); if (!empty($tagname) && !empty($tagdesc)) { $newDocblock->setTag($tagname, $tagdesc); } else { unset($tagsAry[$key]); } } } } } return $newDocblock; }