Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431718
IsEmptyString.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
IsEmptyString.php
View Options
<?php
namespace
Hamcrest\Text
;
/*
Copyright (c) 2009 hamcrest.org
*/
use
Hamcrest\BaseMatcher
;
use
Hamcrest\Core\AnyOf
;
use
Hamcrest\Core\IsNull
;
use
Hamcrest\Description
;
/**
* Matches empty Strings (and null).
*/
class
IsEmptyString
extends
BaseMatcher
{
private
static
$_INSTANCE
;
private
static
$_NULL_OR_EMPTY_INSTANCE
;
private
static
$_NOT_INSTANCE
;
private
$_empty
;
public
function
__construct
(
$empty
=
true
)
{
$this
->
_empty
=
$empty
;
}
public
function
matches
(
$item
)
{
return
$this
->
_empty
?
(
$item
===
''
)
:
is_string
(
$item
)
&&
$item
!==
''
;
}
public
function
describeTo
(
Description
$description
)
{
$description
->
appendText
(
$this
->
_empty
?
'an empty string'
:
'a non-empty string'
);
}
/**
* Matches if value is a zero-length string.
*
* @factory emptyString
*/
public
static
function
isEmptyString
()
{
if
(!
self
::
$_INSTANCE
)
{
self
::
$_INSTANCE
=
new
self
(
true
);
}
return
self
::
$_INSTANCE
;
}
/**
* Matches if value is null or a zero-length string.
*
* @factory nullOrEmptyString
*/
public
static
function
isEmptyOrNullString
()
{
if
(!
self
::
$_NULL_OR_EMPTY_INSTANCE
)
{
self
::
$_NULL_OR_EMPTY_INSTANCE
=
AnyOf
::
anyOf
(
IsNull
::
nullvalue
(),
self
::
isEmptyString
()
);
}
return
self
::
$_NULL_OR_EMPTY_INSTANCE
;
}
/**
* Matches if value is a non-zero-length string.
*
* @factory nonEmptyString
*/
public
static
function
isNonEmptyString
()
{
if
(!
self
::
$_NOT_INSTANCE
)
{
self
::
$_NOT_INSTANCE
=
new
self
(
false
);
}
return
self
::
$_NOT_INSTANCE
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:00 (1 d, 19 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
23/a8/7d22c53bed376708343a48926970
Default Alt Text
IsEmptyString.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment