Completed
Pull Request — master (#68)
by Cristiano
05:36
created

AbstractModel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the php-code-generator package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @license Apache-2.0
8
 */
9
10
namespace gossi\codegen\model;
11
12
use Stringable;
13
14
/**
15
 * Parent of all models
16
 *
17
 * @author Thomas Gossmann
18
 */
19
abstract class AbstractModel implements Stringable {
20
21 23
	/** @var string */
22 23
	protected string $description = '';
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
23
24
	abstract public function getName(): string;
25
26
	/**
27
	 * Returns this description
28
	 *
29
	 * @return string
30
	 */
31 14
	public function getDescription(): string {
32 14
		return $this->description;
33 1
	}
34
35 14
	/**
36 14
	 * Sets the description, which will also be used when generating a docblock
37
	 *
38
	 * @param string|array $description
39
	 *
40
	 * @return $this
41
	 */
42
	public function setDescription(string|array $description): self {
43
		if (is_array($description)) {
44
			$description = implode("\n", $description);
45
		}
46
		$this->description = $description;
47
48
		return $this;
49
	}
50
51
	public function __toString(): string {
52
		return $this->getName();
53
	}
54
}
55