本文整理汇总了PHP中String::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP String::isEmpty方法的具体用法?PHP String::isEmpty怎么用?PHP String::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::isEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isEmpty
/**
* Check if resource is empty
*
* @param resource $resource The resource
*
* @return bool
*/
public static function isEmpty($resource)
{
if (!self::isValid($resource) && null !== $resource) {
return false;
}
return String::isEmpty($resource);
}
示例2: parameterValidation
public static function parameterValidation($file)
{
if (!(String::isEmpty($file, $trim = TRUE) === FALSE)) {
return -1;
}
return getimagesize(new File($file)) ? TRUE : -2;
}
示例3: __construct
/**
* Initializes a new File Object from parent and child or just parent.
*/
public function __construct($parent = "", $child = "") {
$parent = new String($parent);
$child = new String($child);
if($parent->isEmpty())
throw new Exception("File path cannot be empty.");
if($parent->isEmpty() && $child->isEmpty())
throw new Exception("File path cannot be empty.");
if($parent->substring(-1) == $this::seperatorChar && !$child->isEmpty())
$this->path = $parent . $child;
else if(!$child->isEmpty())
$this->path = $parent . $this::seperatorChar . $child;
else
$this->path = $parent;
}
示例4: parameterValidation
/**
* Private method which normalizes email argument validation throughout all of the
* contained methods of this class.
* @param String $email
* @return Int -1 Given argument is not a string
* @return Int -2 Given argument is empty
* @return boolean TRUE argument is a valid email
* @return boolean FALSE $email argument is an invalid email
*/
public static function parameterValidation($email)
{
if (!String::isString($email)) {
return -1;
}
if (String::isEmpty($email, $useTrim = TRUE)) {
return -2;
}
$addressDomain = substr($email, strpos($email, '@') + 1);
$mxRecords = array();
if (!getmxrr($addressDomain, $mxRecords)) {
return -3;
}
return filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE ? -4 : TRUE;
}
示例5: hasMethod
/**
*Checks if a class has a method named $method (boolean mode)
*
*@param String $name class name
*@param String $method method to be checked
*@param Mixed $filters, a set of filters to check for class attributes such as public,
* private, abstract, final, etc. You can specify a string such as "abstract"
* or you can specify a set of filters in an Array like structure
* for instance, specifying $filters to Array('static','public')
* would check for a method named $method that is both static AND public.
* Note: This is affected according to the mode you specify,
* which is by default "all", meaning that every filter you specify
* must be present in the given method.
*
*@param String $mode mode can be any of "all", "any" or "some". The default mode is "all"
*
* "all" mode: the method must contain ALL and *ONLY* the parameters that you
* specify in the $filters argument. If it contains extra attributes it will be
* considered as invalid.
*
* "any" mode: the method must contain at least ONE of the parameters specified
* in $filters. Extra attributes don't matter.
*
* "some" mode: the method must contain all of the attributes specified in
* $filters, but if it contains any other attribute it's still considered
* valid.
*
* is necessary to exist in the given method for it to be TRUE.
*
*
*@param String $msg Exception message if any
*@param Int $exCode Exception code
*
*@return Int -6 if $filters are not null and an empty string was entered
*@return Int -7 if $filters are an array but the array elements are not strings or it's empty
*@return Int -8 ONLY if specified filters are empty
*@return Int -9 ONLY if an invalid filter was specified
*@return Int -10 Method doesn't exists
*@return boolean TRUE if the class has a method named $method
*@return boolean FALSE if the class doesn't has a method named $method
*
*@see self::parameterValidation for other return values
*/
public static function hasMethod($name, $method, $filters = NULL, $mode = "all")
{
$validModes = array('all', 'any', 'some');
$stdValidation = self::parameterValidation($name, $method);
//something went wrong
if (!($stdValidation === TRUE)) {
return $stdValidation;
}
$rc = new \ReflectionClass($name);
//If no filters where specified, then check if the given class has a given method
//and thats it! We don't need further checking if the user hasn't specified any filters.
if (is_null($filters)) {
return $rc->hasMethod($method);
}
//Check if specified $filters are invalid
if (is_string($filters)) {
if (String::isEmpty($filters)) {
return -6;
}
}
//If it's an array but the array is not made of strings
if (!is_null(Vector::isArray($filters)) && !Vector::isMadeOfStrings($filters)) {
return -7;
}
if (is_string($filters)) {
$filters = array($filters);
}
$mode = strtolower($mode);
//Specified $mode is invalid (not one of all,any or some)
if (String::isEmpty($mode) || !in_array($mode, $validModes)) {
return -7;
}
//Check if entered filters are not empty
if (empty($filters)) {
return -8;
}
//Check if entered filters are valid
foreach ($filters as $filter) {
$filter = sprintf('IS_%s', strtoupper($filter));
//If an invalid filter is detected, then return -9
if (!self::hasConstant('\\ReflectionMethod', $filter)) {
return -9;
}
}
//Fetch all class methods
$methods = $rc->getMethods();
$found = FALSE;
foreach ($methods as $m) {
//If the current method is not equal to the selected one then continue
//with the next element in the array
if ($m->name !== $method) {
continue;
}
$found = TRUE;
break;
}
//Method not found
//.........这里部分代码省略.........
示例6: explode
/**
* Convert a string to an array
*
* @param string $string The string
* @param string $delimiter The delimiter
*
* @return array
*/
public static function explode($string, $delimiter)
{
if (!String::isValid($string) || String::isEmpty($string)) {
return false;
}
return explode($delimiter, $string);
}
示例7: isMadeOfStrings
/**
* Validates that an array like structure is made of strings
* @param Mixed $array
* @param boolean $nonEmpty whether or not the strings contained inside the array can be empty
* @return boolean TRUE
* @return Mixed Index position where the failure condition has been found.
*/
public static function isMadeOfStrings($array, $nonEmpty = TRUE)
{
$stdValidation = self::parameterValidation($array);
if (!($stdValidation === TRUE)) {
return $stdValidation;
}
foreach ($array as $key => $val) {
if (is_object($val)) {
if (!Object::hasMethod($val, "__toString")) {
return $key;
}
//print the object
$val = sprintf('%s', $val);
}
if ($nonEmpty && String::isEmpty($val)) {
return $key;
}
}
return TRUE;
}
示例8: random
/**
* Generate random number
*
* @param int $min Minimum value
* @param int $max Maximum value
*
* @return int
*/
public static function random($min, $max = null)
{
if (String::isEmpty($max) || $max > getrandmax()) {
$max = getrandmax();
}
return rand($min, $max);
}
示例9: setVersion
/**
* Sets the requested Exchange server version
* @param string $version
* @return null
* @throws zibo\ZiboException when the provided version is empty
*/
protected function setVersion($version)
{
if ($version === null) {
$version = self::DEFAULT_VERSION;
} elseif (String::isEmpty($version)) {
throw new ZiboException('Provided version is empty');
}
$this->version = $version;
}
示例10: testIsEmpty
public function testIsEmpty()
{
$o = new String(self::MULTI_LINE);
$this->assertFalse($o->isEmpty());
$o = new String('');
$this->assertTrue($o->isEmpty());
}
示例11: Database
$database = new Database();
// initialize class
$database->connect();
// connect to db
LookbookDatabase::$database = $database;
// pass database accessor
//email-redirect.php?email=mrjesuserwinsuarez@gmail.com&action=private-beta&redirect=TRUE
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=signup&redirect=TRUE
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=remove&redirect=TRUE
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=open&redirect
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=Recieved Invitation&redirect
// $action = 'signup';
// $id = 1;
// $email = 'mrjesuserwinsuarez@gmail.com';
//other initialized
$defaultLink = 'http://fashionsponge.com/';
$action = String::isEmpty($_GET['action'], '');
$email = String::isEmpty($_GET['email'], '');
$redirect = String::isEmpty($_GET['redirect'], FALSE);
$qid = !empty($_GET['qid']) ? $_GET['qid'] : 0;
$fname = LookbookDatabase::getFullNameByEmail($email);
//notification send to admin when email clicked action
$to = Program::$adminEmail;
//'mrjesuserwinsuarez@gmail.com,pecotrain1@gmail.com';
$subject = 'invited person clicked the email content ' . $action;
$body = 'Email: ' . $email . "\n" . 'First Name: ' . $fname . "\n" . ' Action: ' . $action;
$from = $email;
$title = 'FS ' . $action;
echo "<div style='display:none' >";
Program::emailInvitationClickedSaveActivityAndRedirectLocation($defaultLink, $action, $redirect, $to, $subject, $body, $from, $title, $qid, $email);
echo "</div>";
示例12: scanTemporaryUploadPath
private function scanTemporaryUploadPath(Io_Path $path_, $subPath_ = '')
{
if (false === String::isEmpty($subPath_) && false === String::endsWith($subPath_, '/')) {
$subPath_ .= '/';
}
foreach ($path_ as $entry) {
if ($entry->isDot()) {
continue;
}
if ($entry->isFile()) {
$this->stashFile($entry->asFile(), $subPath_);
} else {
if ($entry->isDirectory()) {
$this->scanTemporaryUploadPath($entry, $subPath_ . $entry->getName());
}
}
}
$path_->delete(true);
}
示例13: testIsEmpty
public function testIsEmpty()
{
$string = new String();
$this->assertTrue($string->isEmpty());
}