Completed
Pull Request — master (#68)
by Christopher
03:45
created

SimpleStreamProvider::getStreamETag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

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 1
nc 1
nop 2
1
<?php
2
3
namespace POData\Providers\Stream;
4
5
use POData\OperationContext\IOperationContext;
6
use POData\Providers\Metadata\ResourceStreamInfo;
7
use POData\Providers\Metadata\ResourceType;
8
9
class SimpleStreamProvider implements IStreamProvider2
10
{
11 View Code Duplication
    public function getReadStream2($entity, ResourceStreamInfo $resourceStreamInfo = null, $eTag, $checkETagForEquality, IOperationContext $operationContext)
0 ignored issues
show
Duplication introduced by
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...
12
    {
13
        if (null == $resourceStreamInfo) {
14
            return "stream for " . get_class($entity);
15
        }
16
        $name = $resourceStreamInfo->getName();
17
        return $entity->$name;
18
    }
19
20 View Code Duplication
    public function getDefaultStreamEditMediaUri($entity, ResourceType $resourceType, ResourceStreamInfo $resourceStreamInfo = null, IOperationContext $operationContext, $relativeUri = null)
0 ignored issues
show
Unused Code introduced by
The parameter $entity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $resourceType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $operationContext is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
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...
21
    {
22
        if (null == $resourceStreamInfo) {
23
            return $relativeUri . '/$value';
24
        }
25
        return $relativeUri . '/' . $resourceStreamInfo->getName();
26
    }
27
28
    public function getStreamContentType2($entity, ResourceStreamInfo $resourceStreamInfo = null, IOperationContext $operationContext)
29
    {
30
        if (null == $resourceStreamInfo) {
31
            return "*/*";
32
        }
33
        return 'application/octet-stream';
34
    }
35
36 View Code Duplication
    public function getStreamETag2(
0 ignored issues
show
Duplication introduced by
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...
37
        $entity,
38
        ResourceStreamInfo $resourceStreamInfo = null,
39
        IOperationContext $operationContext
40
    ) {
41
        if (null == $resourceStreamInfo) {
42
            return spl_object_hash($entity);
43
        }
44
        $name = $resourceStreamInfo->getName();
45
46
        return sha1($entity->$name);
47
    }
48
49 View Code Duplication
    public function getReadStreamUri2(
0 ignored issues
show
Duplication introduced by
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...
50
        $entity,
51
        ResourceStreamInfo $resourceStreamInfo = null,
52
        IOperationContext $operationContext,
53
        $relativeUri = null
54
    ) {
55
        if (null == $resourceStreamInfo) {
56
            return $relativeUri . '/$value';
57
        }
58
        return $relativeUri . '/' . $resourceStreamInfo->getName();
59
        //let library creates default media url.
60
    }
61
}
62