Completed
Push — master ( 8619b3...819e89 )
by Thomas
05:42
created

src/Header.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace gossi\swagger;
3
4
use gossi\swagger\parts\DescriptionPart;
5
use gossi\swagger\parts\ItemsPart;
6
use gossi\swagger\parts\TypePart;
7
use phootwork\collection\CollectionUtils;
8
use gossi\swagger\parts\ExtensionPart;
9
use phootwork\lang\Arrayable;
10
use phootwork\collection\Map;
11
12
class Header extends AbstractModel implements Arrayable {
13
	
14
	use DescriptionPart;
15
	use TypePart;
16
	use ItemsPart;
17
	use ExtensionPart;
18
	
19
	/** @var string */
20
	private $header;
21
	
22 1
	public function __construct($header, $contents = null) {
23 1
		$this->header = $header;
24 1
		$this->parse($contents === null ? new Map() : $contents);
25 1
	}
26
	
27 1 View Code Duplication
	private function parse($contents = []) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28 1
		$data = CollectionUtils::toMap($contents);
29
		
30
		// parts
31 1
		$this->parseDescription($data);
32 1
		$this->parseType($data);
33 1
		$this->parseItems($data);
34 1
		$this->parseExtensions($data);
35 1
	}
36
	
37 1
	public function toArray() {
38 1
		return $this->export('description', $this->getTypeExportFields(), 'items');
39
	}
40
	
41
	/**
42
	 * Returns the header
43
	 * 
44
	 * @return string
45
	 */
46 1
	public function getHeader() {
47 1
		return $this->header;
48
	}
49
50
}