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