HrryCi   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A outpt() 0 4 1
A hrry() 0 18 4
1
<?php
2
3
namespace Jamosaur\HrryCi;
4
5
/**
6
 * Class HrryCi
7
 * @package Jamosaur\HrryCi
8
 * @author  James Wallen-Jones <[email protected]>
9
 */
10
class HrryCi
11
{
12
    /**
13
     * @var null
14
     */
15
    public $text;
16
    /**
17
     * @var array
18
     */
19
    private $vowels = ['a', 'e', 'i', 'o', 'u'];
20
21
    /**
22
     * HrryCi constructor.
23
     *
24
     * @param null $text
25
     */
26
    public function __construct($text = null)
27
    {
28
        $this->text = $text;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function outpt()
35
    {
36
        return $this->hrry($this->text);
37
    }
38
39
    /**
40
     * @param $input
41
     *
42
     * @return string
43
     */
44
    public function hrry($input)
45
    {
46
        $words = explode(' ', strtolower($input));
47
        $hrry  = [];
48
        foreach ($words as $word) {
49
            if (strlen($word) > 3) {
50
                if (in_array($word[0], $this->vowels)) {
51
                    $word = $word[0] . str_replace($this->vowels, '', $word);
52
                } else {
53
                    $word = str_replace($this->vowels, '', $word);
54
                }
55
            }
56
            $word   = str_replace(['you'], 'u', $word);
57
            $hrry[] = $word;
58
        }
59
60
        return implode(' ', $hrry);
61
    }
62
}
63