Completed
Push — master ( 2baed6...2076df )
by WEBEWEB
01:22
created

ArrayWordsTrait::getNumberWords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2020 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\ThirdParty\OcrLad\Model\Attribute;
13
14
use WBW\Library\Core\ThirdParty\OcrLad\Model\Word;
15
16
/**
17
 * Array words trait.
18
 *
19
 * @author webeweb <https://github.com/webeweb>
20
 * @package WBW\Library\Core\ThirdParty\OcrLad\Model\Attribute
21
 */
22
trait ArrayWordsTrait {
23
24
    /**
25
     * Words.
26
     *
27
     * @var Word[]
28
     */
29
    private $words;
30
31
    /**
32
     * Add a word.
33
     *
34
     * @param Word $word The word.
35
     */
36
    public function addWord(Word $word) {
37
        $this->words[] = $word;
38
        return $this;
39
    }
40
41
    /**
42
     * Get the number of words.
43
     *
44
     * @return int Returns the number of words.
45
     */
46
    public function getNumberWords() {
47
        return count($this->words);
48
    }
49
50
    /**
51
     * Get the words.
52
     *
53
     * @return Word[] Returns the words.
54
     */
55
    public function getWords() {
56
        return $this->words;
57
    }
58
59
    /**
60
     * Determines if this instance has words.
61
     *
62
     * @return bool Returns true in case of success, false otherwise.
63
     */
64
    public function hasWords() {
65
        return 1 <= $this->getNumberWords();
66
    }
67
68
    /**
69
     * Set the words.
70
     *
71
     * @param Word[] $words The words.
72
     */
73
    protected function setWords(array $words) {
74
        $this->words = $words;
75
        return $this;
76
    }
77
}