HrryCi::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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