Completed
Pull Request — master (#102)
by Litera
10:11 queued 01:46
created

ExcelFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A create() 0 14 1
1
<?php
2
3
namespace App\Factories;
4
5
/**
6
 * ExcelFactory
7
 *
8
 * factory to create instance of PHPExcel
9
 *
10
 * @created 2016-07-07
11
 * @author Tomas Litera <[email protected]>
12
 */
13
class ExcelFactory
14
{
15
	/** @var Excel */
16
	private $excel;
17
	private $creator = 'Junák - český skaut, Kapitanát vodních skautů, z. s.';
18
	private $lastModifiedBy = 'Srazy VS';
19
	private $title = 'Srazy VS: Export';
20
	private $subject = 'Export';
21
	private $description = 'Srazy VS CMS: export dat';
22
	private $keywords = 'sraz vs export xlsx';
23
	private $category = 'Export dat';
24
25
	/** Constructor */
26
	public function __construct(array $configuration)
27
	{
28
		//var_dump($configuration);
29
		//exit;
30
		$this->creator 			= $configuration['creator'];
31
		$this->lastModifiedBy 	= $configuration['lastModifiedBy'];
32
		$this->title 			= $configuration['title'];
33
		$this->subject 			= $configuration['subject'];
34
		$this->description 		= $configuration['description'];
35
		$this->keywords 		= $configuration['keywords'];
36
		$this->category 		= $configuration['category'];
37
	}
38
39
	/**
40
	 * Return new PHPExcel with few settings
41
	 *
42
	 * @return	PHPExcel;
0 ignored issues
show
Documentation introduced by
The doc-type PHPExcel; could not be parsed: Expected "|" or "end of type", but got ";" at position 8. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
43
	 */
44
	public function create()
45
	{
46
		$this->excel = new \PHPExcel();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \PHPExcel() of type object<PHPExcel> is incompatible with the declared type object<App\Factories\Excel> of property $excel.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
48
		$this->excel->getProperties()->setCreator($this->creator)
49
			->setLastModifiedBy($this->lastModifiedBy)
50
			->setTitle($this->title)
51
			->setSubject($this->subject)
52
			->setDescription($this->description)
53
			->setKeywords($this->keywords)
54
			->setCategory($this->category);
55
56
		return $this->excel;
57
	}
58
}
59