Beispiel #1
0
 /**
  * Returns a Boolean with a value represented by the specified String.
  *
  * If the passed string has the primitive value TRUE or 1 then the
  * returned object is initialized with the primitive value TRUE else
  * with FALSE.
  *
  * @param \AppserverIo\Lang\Strng $string Holds the String object to get the Boolean representation for
  *
  * @return \AppserverIo\Lang\Boolean The Boolean object representing the specified String.
  */
 public static function valueOf(Strng $string)
 {
     // if the passed value is "true" or "1" then return a new Boolean
     // object initialized with true
     if ($string->equals(new Strng("1")) || $string->equals(new Strng("true")) || $string->equals(new Strng("yes")) || $string->equals(new Strng("on")) || $string->equals(new Strng("y"))) {
         return new Boolean(true);
     }
     // else return a new Boolean object initialized with false
     return new Boolean(false);
 }
Beispiel #2
0
 /**
  * This test checks the Strng's valueOf method.
  *
  * @return void
  */
 public function testValueOf()
 {
     // initialize a new Strng instance
     $string = Strng::valueOf($value = 'value of');
     // check that Strng was successfully concatenated
     $this->assertTrue($string->equals(new Strng($string)));
 }
Beispiel #3
0
 /**
  * This method returns the class as
  * a string representation.
  *
  * @return string The objects string representation
  * @see \AppserverIo\Lang\Object::__toString()
  */
 public function __toString()
 {
     $string = new Strng($this->value);
     return $string->stringValue();
 }
Beispiel #4
0
 /**
  * Returns a new String, containing the concatenated value
  * of the this string with the passed one.
  *
  * @param \AppserverIo\Lang\Strng $string The String to concatenate
  *
  * @return \AppserverIo\Lang\Strng The concatenated String
  */
 public function concat(Strng $string)
 {
     return new Strng($this->stringValue() . $string->stringValue());
 }