Announce   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getString() 0 23 3
1
<?php
2
3
/**
4
 * Announce
5
 * @copyright Copyright (c) 2011 - 2013 Aleksandr Torosh (http://wezoom.com.ua)
6
 * @author Aleksandr Torosh <[email protected]>
7
 */
8
9
namespace Application\Mvc\Helper;
10
11
class Announce
12
{
13
14
    public function getString($incomeString, $num = 300)
15
    {
16
        $stringStriped = strip_tags($incomeString);
17
        if (!$stringStriped) {
18
            return;
19
        }
20
21
        $textBr = str_replace(array("\r\n", "\r", "\n"), "<br>", $stringStriped);
22
        $string = mb_substr(strip_tags($textBr), 0, 300, 'utf-8');
23
24
        if (mb_strlen($string, 'utf-8') < $num) {
25
            return $string;
26
        }
27
28
        $subString = mb_substr($string, 0, $num, 'utf-8');
29
        $array     = explode(' ', $subString);
30
31
        $array[count($array) - 1] = '...';
32
        $output                   = implode(' ', $array);
33
34
        return $output;
35
36
    }
37
38
}
39