GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 42c65a...a98f71 )
by
unknown
07:18
created

BindingsObjectFactory::createPropertyIntegerData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
namespace Dkd\PhpCmis\DataObjects;
3
4
/**
5
 * This file is part of php-cmis-lib.
6
 *
7
 * (c) Sascha Egerer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
use Dkd\PhpCmis\Data\AceInterface;
14
use Dkd\PhpCmis\Data\BindingsObjectFactoryInterface;
15
use Dkd\PhpCmis\Data\PropertyDataInterface;
16
use Dkd\PhpCmis\Definitions\PropertyBooleanDefinitionInterface;
17
use Dkd\PhpCmis\Definitions\PropertyDateTimeDefinitionInterface;
18
use Dkd\PhpCmis\Definitions\PropertyDecimalDefinitionInterface;
19
use Dkd\PhpCmis\Definitions\PropertyDefinitionInterface;
20
use Dkd\PhpCmis\Definitions\PropertyHtmlDefinitionInterface;
21
use Dkd\PhpCmis\Definitions\PropertyIdDefinitionInterface;
22
use Dkd\PhpCmis\Definitions\PropertyIntegerDefinitionInterface;
23
use Dkd\PhpCmis\Definitions\PropertyStringDefinitionInterface;
24
use Dkd\PhpCmis\Definitions\PropertyUriDefinitionInterface;
25
use Dkd\PhpCmis\Enum\BaseTypeId;
26
use Dkd\PhpCmis\Exception\CmisInvalidArgumentException;
27
use Dkd\PhpCmis\Exception\CmisRuntimeException;
28
use GuzzleHttp\Stream\StreamInterface;
29
30
/**
31
 * CMIS binding object factory implementation.
32
 */
33
class BindingsObjectFactory implements BindingsObjectFactoryInterface
34
{
35
    /**
36
     * Create a AccessControlEntry for the given principal and permissions
37
     *
38
     * @param string $principal
39
     * @param string[] $permissions
40
     * @return AccessControlEntry
41
     */
42 1
    public function createAccessControlEntry($principal, array $permissions)
43
    {
44 1
        return new AccessControlEntry(new Principal($principal), $permissions);
45
    }
46
47
    /**
48
     * @param AceInterface[] $aces
49
     * @return AccessControlList
50
     */
51 1
    public function createAccessControlList(array $aces)
52
    {
53 1
        return new AccessControlList($aces);
54
    }
55
56
    /**
57
     * TODO check if this method is required at all in the php implementation
58
     *
59
     * @param string $filename
60
     * @param integer $length
61
     * @param string $mimeType
62
     * @param mixed $stream @TODO define datatype
63
     * @return StreamInterface
64
     */
65
    public function createContentStream($filename, $length, $mimeType, $stream)
66
    {
67
        // TODO: Implement createContentStream() method.
68
    }
69
70
    /**
71
     * @param PropertyDataInterface[] $propertiesData
72
     * @return Properties
73
     */
74 1
    public function createPropertiesData(array $propertiesData)
75
    {
76 1
        $properties = new Properties();
77 1
        $properties->addProperties($propertiesData);
78 1
        return $properties;
79
    }
80
81
    /**
82
     * @param PropertyDefinitionInterface $propertyDefinition
83
     * @param array $values
84
     * @return PropertyDataInterface
85
     */
86 9
    public function createPropertyData(PropertyDefinitionInterface $propertyDefinition, array $values)
87
    {
88 9
        if ($propertyDefinition instanceof PropertyStringDefinitionInterface) {
89 1
            return $this->createPropertyStringData($propertyDefinition->getId(), $values);
90 8
        } elseif ($propertyDefinition instanceof PropertyBooleanDefinitionInterface) {
91 1
            return $this->createPropertyBooleanData($propertyDefinition->getId(), $values);
92 7
        } elseif ($propertyDefinition instanceof PropertyIdDefinitionInterface) {
93 1
            return $this->createPropertyIdData($propertyDefinition->getId(), $values);
94 6
        } elseif ($propertyDefinition instanceof PropertyDateTimeDefinitionInterface) {
95 1
            return $this->createPropertyDateTimeData($propertyDefinition->getId(), $values);
96 5
        } elseif ($propertyDefinition instanceof PropertyDecimalDefinitionInterface) {
97 1
            return $this->createPropertyDecimalData($propertyDefinition->getId(), $values);
98 4
        } elseif ($propertyDefinition instanceof PropertyHtmlDefinitionInterface) {
99 1
            return $this->createPropertyHtmlData($propertyDefinition->getId(), $values);
100 3
        } elseif ($propertyDefinition instanceof PropertyIntegerDefinitionInterface) {
101 1
            return $this->createPropertyIntegerData($propertyDefinition->getId(), $values);
102 2
        } elseif ($propertyDefinition instanceof PropertyUriDefinitionInterface) {
103 1
            return $this->createPropertyUriData($propertyDefinition->getId(), $values);
104
        }
105 1
        throw new CmisRuntimeException(sprintf('Unknown property definition: %s', get_class($propertyDefinition)));
106
    }
107
108
    /**
109
     * @param string $id
110
     * @param boolean[] $values
111
     * @return PropertyBoolean
112
     */
113 2
    public function createPropertyBooleanData($id, array $values)
114
    {
115 2
        return new PropertyBoolean($id, $values);
116
    }
117
118
    /**
119
     * @param string $id
120
     * @param \DateTime[] $values
121
     * @return PropertyDateTime
122
     */
123 2
    public function createPropertyDateTimeData($id, array $values)
124
    {
125 2
        return new PropertyDateTime($id, $values);
126
    }
127
128
    /**
129
     * @param string $id
130
     * @param float[] $values
131
     * @return PropertyDecimal
132
     */
133 2
    public function createPropertyDecimalData($id, array $values)
134
    {
135 2
        return new PropertyDecimal($id, $values);
136
    }
137
138
    /**
139
     * @param string $id
140
     * @param string[] $values
141
     * @return PropertyHtml
142
     */
143 2
    public function createPropertyHtmlData($id, array $values)
144
    {
145 2
        return new PropertyHtml($id, $values);
146
    }
147
148
    /**
149
     * @param string $id
150
     * @param string[] $values
151
     * @return PropertyId
152
     */
153 2
    public function createPropertyIdData($id, array $values)
154
    {
155 2
        return new PropertyId($id, $values);
156
    }
157
158
    /**
159
     * @param string $id
160
     * @param integer[] $values
161
     * @return PropertyInteger
162
     */
163 2
    public function createPropertyIntegerData($id, array $values)
164
    {
165 2
        return new PropertyInteger($id, $values);
166
    }
167
168
    /**
169
     * @param string $id
170
     * @param string[] $values
171
     * @return PropertyString
172
     */
173 2
    public function createPropertyStringData($id, array $values)
174
    {
175 2
        return new PropertyString($id, $values);
176
    }
177
178
    /**
179
     * @param string $id
180
     * @param string[] $values
181
     * @return PropertyUri
182
     */
183 2
    public function createPropertyUriData($id, array $values)
184
    {
185 2
        return new PropertyUri($id, $values);
186
    }
187
188
    /**
189
     * Get a type definition object by its base type id
190
     *
191
     * @param string $baseTypeIdString
192
     * @param string $typeId
193
     * @return FolderTypeDefinition|DocumentTypeDefinition|RelationshipTypeDefinition|PolicyTypeDefinition|ItemTypeDefinition|SecondaryTypeDefinition
194
     * @throws CmisInvalidArgumentException Exception is thrown if the base type exists in the BaseTypeId enumeration
195
     *      but is not implemented here. This could only happen if the base type enumeration is extended which requires
196
     *      a CMIS specification change.
197
     */
198 1
    public function getTypeDefinitionByBaseTypeId($baseTypeIdString, $typeId)
199
    {
200 1
        $baseTypeId = BaseTypeId::cast($baseTypeIdString);
201
202
        if ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_FOLDER))) {
203
            $baseType = new FolderTypeDefinition($typeId);
204
        } elseif ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_DOCUMENT))) {
205
            $baseType = new DocumentTypeDefinition($typeId);
206
        } elseif ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_RELATIONSHIP))) {
207
            $baseType = new RelationshipTypeDefinition($typeId);
208
        } elseif ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_POLICY))) {
209
            $baseType = new PolicyTypeDefinition($typeId);
210
        } elseif ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_ITEM))) {
211
            $baseType = new ItemTypeDefinition($typeId);
212
        } elseif ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_SECONDARY))) {
213
            $baseType = new SecondaryTypeDefinition($typeId);
214
        } else {
215
            // @codeCoverageIgnoreStart
216
            // this could only happen if a new baseType is added to the enumeration and not implemented here.
217
            throw new CmisInvalidArgumentException(
218
                sprintf('The given type definition "%s" could not be converted.', $baseTypeId)
219
            );
220
            // @codeCoverageIgnoreEnd
221
        }
222
223
        $baseType->setBaseTypeId($baseTypeId);
224
225
        return $baseType;
226
    }
227
}
228