Completed
Push — master ( 0ef921...49b538 )
by Martijn
03:08
created

Statement   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __toString() 0 7 3
A getCommand() 0 4 1
A getData() 0 4 1
A getFile() 0 4 1
A getLine() 0 4 1
1
<?php
2
3
namespace SwaggerGen;
4
5
/**
6
 * Represents a command statement, which links the code parsers to the document
7
 * generator side of SwaggerGen.
8
 *
9
 * @package    SwaggerGen
10
 * @author     Martijn van der Lee <[email protected]>
11
 * @copyright  2014-2015 Martijn van der Lee
12
 * @license    https://opensource.org/licenses/MIT MIT
13
 */
14
class Statement
15
{
16
17
	private $command;
18
	private $data;
19
	private $file;
20
	private $line;
21
22
	public function __construct($command, $data = null, $file = null, $line = null)
23
	{
24
		$this->command = $command;
25
		$this->data = $data;
26
		$this->file = $file;
27
		$this->line = $line;
28
	}
29
30
	public function __toString()
31
	{
32
		$message = "Command '{$this->command}'";
33
		$message .= $this->data ? " with data '{$this->data}'" : ' without data';
34
		$message .= $this->file ? " from static text" : " in file '{$this->file}' on line {$this->line}";
35
		return $message;
36
	}
37
38
	/**
39
	 * Get the command part of this statement
40
	 * @return string single word, without spaces
41
	 */
42
	public function getCommand()
43
	{
44
		return $this->command;
45
	}
46
47
	/**
48
	 * Get the data of this statement
49
	 * @return string may contain spaces
50
	 */
51
	public function getData()
52
	{
53
		return $this->data;
54
	}
55
56
	/**
57
	 * Get the file (if available) where this statement was parsed from
58
	 * @return string|null the full filename or null of from static text
59
	 */
60
	public function getFile()
61
	{
62
		return $this->file;
63
	}
64
65
	/**
66
	 * Get the line number where this statement was found
67
	 * @return int|null the line number
68
	 */
69
	public function getLine()
70
	{
71
		return $this->line;
72
	}
73
74
}
75