lithium\g11n\Multibyte::strlen PHP Method

strlen() public static method

Gets the string length. Multibyte enabled version of strlen().
public static strlen ( string $string, array $options = [] ) : integer
$string string The string being measured for length.
$options array Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default.
return integer The length of the string on success.
    public static function strlen($string, array $options = array())
    {
        $defaults = array('name' => 'default');
        $options += $defaults;
        return static::adapter($options['name'])->strlen($string);
    }

Usage Example

 public function apply($testable, array $config = array())
 {
     extract($config += $this->config);
     foreach ($testable->lines() as $i => $line) {
         $tabBounty = substr_count($line, "\t") * ($tabWidth - 1);
         $strlen = Multibyte::strlen($line, array('name' => 'li3_quality'));
         $totalLength = $length = $tabBounty + $strlen;
         if ($totalLength > $hardLimit) {
             $this->addViolation(array('message' => "Maximum line length of {$hardLimit} exceeded", 'line' => $i + 1, 'position' => $length));
         } elseif ($softLimit && $totalLength > $softLimit) {
             $this->addWarning(array('message' => "Soft line length of {$softLimit} exceeded", 'line' => $i + 1, 'position' => $length));
         }
     }
 }
All Usage Examples Of lithium\g11n\Multibyte::strlen