Strings
[ class tree: Strings ] [ index: Strings ] [ all elements ]

Class: Strings

Source Location: /Strings.php

Class Overview


This class manages Strings objects. Many functions are available: RemoveSpaces(), RemoveAccent(), QuoteStrip(), etc.


Author(s):

Version:

  • 2.3

Variables

Methods


Child classes:

HTML
This class manages HTML objects.
PHPCode
Created on 1 april 09
STRdates
This class manages STRdates objects. It is used to manipulate dates strings.
STRemailAddresses
This class manages STRemailAddresses objects. It is used to manipulate email addresses strings.
STRip
This class manages time objects.
STRLeetSpeak
This class manages LeetSpeak objects. This class manages STRLeetSpeak strings objects.
STRlines
This class manages lines (strings) objects.
STRnumbers
This class manages STRnumbers objects.
STRpasswords
This class manages STRpasswords objects.
STRphones
This class manages STRphones objects.
STRpostcodes
This class manages STRpostcodes objects. It is used to manipulate postcode strings.
STRregexs
This class manages regular expressions objects.
STRtimes
This class manages time objects.
STRwebsites
This class manages websites objects.

Class Details

[line 36]
This class manages Strings objects. Many functions are available: RemoveSpaces(), RemoveAccent(), QuoteStrip(), etc.

Created on 05 sep 06

Changes: 2.2 -> 2.3: 16 jul 09 updated: file is PEAR compatible 2.1 to 2.2: 22 jun 09 added: stringHasNumbers() function 2.0 to 2.1: 25 may 09 updated: placing error message in $this->error for console() function 1.0 to 2.0: updated: phpdoc compatible in the way to generate documentation




Tags:



[ Top ]


Class Variables

$api_render =

[line 97]

Variable that defines the API rendering the message

The current available APIs are Terminal or xHTML browser




Tags:

access:  public

Type:   string


[ Top ]

$charset =  "UTF-8"

[line 50]

Variable that defines charset

The charset of Strings::value is defined by this variable




Tags:

access:  public

Type:   string


[ Top ]

$colors = array(
        "cli"   =>  array(
            "debug_begin"   =>  "\033[31m\033[01m",
            "debug_end"     =>  "\033[00m",
            "error_begin"   =>  "\033[31m\033[01m\007",
            "error_end"     =>  "\033[00m",
            "warning_begin" =>  "\033[33m\033[01m",
            "warning_end"   =>  "\033[00m",
            "success_begin" =>  "\033[32m\033[01m",
            "success_end"   =>  "\033[00m",
            "newline"       =>  "\n"
        ),"html"=>array("debug_begin"=>"<font color=\"red\"><b>","debug_end"=>"</b></font>","error_begin"=>"<font color=\"red\"><b>","error_end"=>"</b></font>","warning_begin"=>"<font color=\"orange\"><b>","warning_end"=>"</b></font>","success_begin"=>"<font color=\"green\"><b>","success_end"=>"</b></font>","newline"=>"<br/>\n"))

[line 69]

Variable that lists colors for messages

Those colors are defined for specific message type AND specific output




Tags:

access:  protected

Type:   array


[ Top ]

$directoutput =  true

[line 103]

Variable that defines if the message is directly outputted

If the variable is equal to false, the message will be temporized and API must not be self selected




Tags:

access:  public

Type:   bool


[ Top ]

$error =

[line 111]

Variable used to render errors

This variable contains the error message and the error number




Tags:

access:  public

Type:   array


[ Top ]

$msgtypes = array(
        "debug", 
        "error", 
        "warning", 
        "success"
    )

[line 58]

Variable that lists message types

Those message types are used to render console messages




Tags:

access:  protected

Type:   array


[ Top ]

$value =

[line 43]

Variable that contains string to be handled

This variable is used as main variable in all Strings::functions()




Tags:

access:  public

Type:   string


[ Top ]



Class Methods


constructor __construct [line 139]

Strings __construct( [array $aParams = null], [string $sAction = null])

Construction function

This function is used when object is generated. It places variables in "$this" var and can launch function

  1.  <?php
  2.  $aParams     array("value"=>"   This      is   a     test   ");
  3.  $oStrings    new Strings($aParams"RemoveSpaces");
  4.  echo $oStrings->value;
  5.  // This is a test
  6.  ?>




Tags:

since:  Version 1.0


Parameters:

array   $aParams   array containing variable names and their value ($variablename => $value)
string   $sAction   string containing action to perform on object creation

[ Top ]

method console [line 622]

string console( string $msg, string $msgtype, bool $this->directoutput)

Console function

This function is used to render errors, logs, debugs, etc. Result is stored in $this->value and returned.

  1.  <?php
  2.  $oStrings new Strings();
  3.  $msg      "This is an error";
  4.  $msgtype  "error";
  5.  echo $oStrings->console($msg$msgtype);
  6.  // [red colored]ERROR: This is an error[/red colored]
  7.  ?>




Tags:

return:  processed text
staticvar:  array $this->msgtypes: array corresponding to the types list
since:  version 1.0


Parameters:

string   $msg   text to be processed (required)
string   $msgtype   string corresponding to message type ($this->msgtypes) (required)
bool   $this->directoutput   defines if the message needs to be stored in a var or directly echoed

[ Top ]

method IsUTF8 [line 434]

bool IsUTF8( string $this->value)

UTF8 detection function

This function is used to detect if encoding is UTF-8. Result is returned.

  1.  <?php
  2.  $oStrings        new Strings();
  3.  $oStrings->value $utf8_string;
  4.  echo $oStrings->IsUTF8();
  5.  // true
  6.  ?>




Tags:

return:  true if the string is in UTF8
since:  version 1.0
usedby:  Strings::ToUTF8()


Parameters:

string   $this->value   text to be processed (required)

[ Top ]

method QuoteStrip [line 528]

string QuoteStrip( [string $tostrip = "ALL"], string $this->value)

Quotes stripping function

This function is used to strip " and ' which are around a string. Result is stored in $this->value and returned.

  1.  <?php
  2.  $oStrings        new Strings();
  3.  $oStrings->value "'This is a test'";
  4.  echo $oStrings->QuoteStrip();
  5.  // This is a test
  6.  ?>




Tags:

return:  processed text
since:  version 1.0


Parameters:

string   $this->value   text to be processed (required)
string   $tostrip   this var can be defined to ALL, simple or double. It defines the quotes to be removed.

[ Top ]

method RemoveAccent [line 470]

string RemoveAccent( string $this->value)

Accents removal function

This function is used to remove accent from a string. Result is stored in $this->value and returned.

  1.  <?php
  2.  $oStrings        new Strings();
  3.  $oStrings->value $accents_string;
  4.  echo $oStrings->RemoveAccent();
  5.  // $nonaccent_string
  6.  ?>




Tags:

return:  processed text
since:  version 1.0
uses:  Strings::ToUTF8()


Parameters:

string   $this->value   text to be processed (required)

[ Top ]

method RemoveSpaces [line 573]

string RemoveSpaces( string $this->value)

Spaces removal function

This function is used to remove spaces that are not needed. Result is stored in $this->value and returned.

  1.  <?php
  2.  $oStrings        new Strings();
  3.  $oStrings->value "   This      is   a     test   ");
  4.  $oStrings->RemoveSpaces();
  5.  echo $oStrings->value;
  6.  // This is a test
  7.  ?>




Tags:

return:  processed text
since:  version 1.0


Parameters:

string   $this->value   text to be processed (required)

[ Top ]

method stringHasNumbers [line 698]

bool stringHasNumbers( [ $nullable = true], string $this->value)

Numbers detection function

This function is used check if a string includes numbers Result is returned.

  1.  <?php
  2.  $oStrings        new Strings("This is an error");
  3.  echo $oStrings->stringHasNumbers();
  4.  // 0
  5.  ?>




Tags:

return:  true if string has numbers
since:  version 2.2


Parameters:

string   $this->value   text to be checked (required)
   $nullable  

[ Top ]

method ToUTF8 [line 399]

string ToUTF8( string $this->value)

UTF8 conversion function

This function is used to format text to UTF8 encoding. Result is stored in $this->value and returned.

  1.  <?php
  2.  $oStrings        new Strings();
  3.  $oStrings->value $iso85591_string;
  4.  echo $oStrings->ToUTF8();
  5.  // $utf8_string
  6.  ?>




Tags:

return:  generated text
since:  version 1.0
usedby:  Strings::RemoveAccent()
uses:  Strings::IsUTF8()


Parameters:

string   $this->value   text to be processed (required)

[ Top ]

method ucwordsw [line 180]

string ucwordsw( [bool $minimize = true], string $this->value)

Special uppercase function

This function is used to put uppercase the first char of each word except special words like 'of', 'the', 'a', etc. Result is stored in $this->value and returned

  1.  <?php
  2.  $oStrings        new Strings();
  3.  $oStrings->value "THIS IS THE STORY OF A DOG";
  4.  echo $oStrings->ucwordsw(true);
  5.  // This Is the Story of a Dog
  6.  ?>




Tags:

return:  generated text
since:  version 1.0


Parameters:

string   $this->value   text to be processed (required)
bool   $minimize   lowercases text before processing

[ Top ]


Documentation generated on Wed, 26 Aug 2009 12:30:45 +0200 by phpDocumentor 1.4.1