Completed
Pull Request — develop (#251)
by
unknown
14:19 queued 06:05
created

ModuleOptions::getAttachmentsMimeType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
namespace Cv\Options;
11
12
use Zend\Stdlib\AbstractOptions;
13
use Zend\ServiceManager\ServiceManager;
14
15
/**
16
 * Default options of the CV Module
17
 */
18
class ModuleOptions extends AbstractOptions
19
{
20
21
    /**
22
     * maximum size in bytes of an attachment. Default 5MB
23
     *
24
     * @var int $attachmentsMaxSize
25
     */
26
    protected $attachmentsMaxSize = 5000000;
27
28
    /**
29
     * valid Mime-Types of attachments
30
     *
31
     * @var array $attachmentsMimeType
32
     */
33
    protected $attachmentsMimeType = array('image','applications/pdf',
34
        'application/x-pdf',
35
        'application/acrobat',
36
        'applications/vnd.pdf',
37
        'text/pdf',
38
        'text/x-pdf');
39
40
    /**
41
     * maximum number of attachments. Default 3
42
     *
43
     * @var int $attachmentsCount
44
     */
45
    protected $attachmentsCount = 3;
46
47
    /**
48
     * Gets the maximum size of attachments in bytes
49
     *
50
     * @return int
51
     */
52
    public function getAttachmentsMaxSize()
53
    {
54
        return $this->attachmentsMaxSize;
55
    }
56
    
57
    /**
58
     * Sets the maximum size of attachments in bytes
59
     *
60
     * @param int $size
61
     * @return ModuleOptions
62
     */
63
    public function setAttachmentsMaxSize($size)
64
    {
65
        $this->attachmentsMaxSize = $size;
66
        return $this;
67
    }
68
69
    /**
70
     * Gets the the allowed Mime-Types for attachments
71
     *
72
     * @return array
73
     */
74
    public function getAttachmentsMimeType()
75
    {
76
        return $this->attachmentsMimeType;
77
    }
78
    /**
79
     * Sets the maximum size of attachments in bytes
80
     *
81
     * @param array $mime
82
     * @return ModuleOptions
83
     */
84
    public function setAttachmentsMimeType(array $mime)
85
    {
86
        $this->attachmentsMimeType = $mime;
87
        return $this;
88
    }
89
90
    /**
91
     * Gets the the maximum number of allowed attachments
92
     *
93
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
94
     */
95
    public function getAttachmentsCount()
96
    {
97
        return $this->attachmentsCount;
98
    }
99
    /**
100
     * Sets the maximum number of allowed attachments
101
     *
102
     * @param string $number
103
     * @return ModuleOptions
104
     */
105
    public function setAttachmentsCount($number)
106
    {
107
        $this->attachmentsCount = $number;
0 ignored issues
show
Documentation Bug introduced by
The property $attachmentsCount was declared of type integer, but $number is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
108
        return $this;
109
    }
110
    
111
    /**
112
     * @param ServiceManager $serviceLocator
113
     * @return AuthAggregateListener
0 ignored issues
show
Documentation introduced by
Should the return type not be ModuleOptions?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
114
     */
115
    public static function factory(ServiceManager $serviceLocator)
116
    {
117
        $config = $serviceLocator->get('Config');
118
        return new static(isset($config['cv_options']) ? $config['cv_options'] : null);
119
    }
120
}