Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
DocblockTrait
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
9
100.00% covered (success)
100.00%
1 / 1
 setDocblock
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getDocblock
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasDocblock
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDesc
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getDesc
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasDesc
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Code\Generator\Traits;
15
16use Pop\Code\Generator\DocblockGenerator;
17
18/**
19 * Docblock trait
20 *
21 * @category   Pop
22 * @package    Pop\Code
23 * @author     Nick Sagona, III <dev@nolainteractive.com>
24 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
25 * @license    http://www.popphp.org/license     New BSD License
26 * @version    5.0.0
27 */
28trait DocblockTrait
29{
30
31    /**
32     * Docblock generator object
33     * @var ?DocblockGenerator
34     */
35    protected ?DocblockGenerator $docblock = null;
36
37    /**
38     * Set the docblock generator object
39     *
40     * @param  DocblockGenerator $docblock
41     * @return static
42     */
43    public function setDocblock(DocblockGenerator $docblock): static
44    {
45        $this->docblock = $docblock;
46        return $this;
47    }
48
49    /**
50     * Access the docblock generator object
51     *
52     * @return DocblockGenerator|null
53     */
54    public function getDocblock(): DocblockGenerator|null
55    {
56        return $this->docblock;
57    }
58
59    /**
60     * Has docblock generator object
61     *
62     * @return bool
63     */
64    public function hasDocblock(): bool
65    {
66        return ($this->docblock !== null);
67    }
68
69    /**
70     * Set the docblock description
71     *
72     * @param  ?string $desc
73     * @return static
74     */
75    public function setDesc(?string $desc = null): static
76    {
77        if ($this->docblock !== null) {
78            $this->docblock->setDesc($desc);
79        } else {
80            $this->docblock = new DocblockGenerator($desc);
81        }
82        return $this;
83    }
84
85    /**
86     * Get the docblock description
87     *
88     * @return string|null
89     */
90    public function getDesc(): string|null
91    {
92        return ($this->docblock !== null) ? $this->docblock->getDesc() : null;
93    }
94
95    /**
96     * Has a docblock description
97     *
98     * @return bool
99     */
100    public function hasDesc(): bool
101    {
102        return ($this->docblock !== null) ? $this->docblock->hasDesc() : false;
103    }
104
105}