bigram()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
c 1
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
use TextUtils\NGram;
4
5
if (! function_exists('bigram')) {
6
    /**
7
     * Generate a bi-gram for the provided string.
8
     *
9
     * @param string $text
10
     *
11
     * @throws \TextUtils\Exceptions\InvalidArgumentException
12
     *
13
     * @return array
14
     */
15
    function bigram(string $text)
16
    {
17
        return NGram::bigram($text);
18
    }
19
}
20
21
if (! function_exists('trigram')) {
22
    /**
23
     * Generate a tri-gram for the provided string.
24
     *
25
     * @param string $text
26
     *
27
     * @throws \TextUtils\Exceptions\InvalidArgumentException
28
     *
29
     * @return array
30
     */
31
    function trigram(string $text)
32
    {
33
        return NGram::trigram($text);
34
    }
35
}
36
37
if (! function_exists('ngram')) {
38
    /**
39
     * Generate a tri-gram for the provided string.
40
     *
41
     * @param string $text
42
     * @param int    $length
43
     *
44
     * @throws \TextUtils\Exceptions\InvalidArgumentException
45
     *
46
     * @return array
47
     */
48
    function ngram(string $text, int $length = 3)
49
    {
50
        return NGram::for($text, $length);
51
    }
52
}
53