Word::getPluralised()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 3
eloc 2
nc 4
nop 1
crap 3
1
<?php
2
3
namespace BestServedCold\PhalueObjects\VOString;
4
5
use BestServedCold\PhalueObjects\Exception\InvalidTypeException;
6
use BestServedCold\PhalueObjects\VOString;
7
use Doctrine\Common\Inflector\Inflector;
8
9
/**
10
 * Class Word
11
 *
12
 * @package BestServedCold\PhalueObjects\VOString
13
 */
14
class Word extends VOString
15
{
16
    /**
17
     * Word constructor.
18
     *
19
     * @param $value
20
     */
21 6
    public function __construct($value)
22
    {
23 6
        parent::__construct($value);
24
25 6
        if (! preg_match('/[A-za-z]/', $this->getValue())) {
26
            throw new InvalidTypeException($value, ['word']);
27
        }
28 6
    }
29
30
    /**
31
     * @param  integer $count
0 ignored issues
show
Documentation introduced by
Should the type for parameter $count not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
32
     * @return string
33
     */
34 6
    public function getPluralised($count = null)
35
    {
36 6
        return $count === null || $count > 1 ? Inflector::pluralize($this->getValue()) : $this->getValue();
37
    }
38
}
39