hasRegistrationsByEventCodeAndEmail()   B
last analyzed

Complexity

Conditions 11
Paths 7

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 7.3166
c 0
b 0
f 0
cc 11
nc 7
nop 5

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Wabel\CertainAPI\Ressources;
3
4
use Wabel\CertainAPI\Interfaces\CertainRessourceInterface;
5
use Wabel\CertainAPI\CertainRessourceAbstract;
6
7
/**
8
 * RegistrationCertain about the Registration entity
9
 *
10
 * @author rbergina
11
 */
12
class RegistrationCertain extends CertainRessourceAbstract implements CertainRessourceInterface
13
{
14
    public function getRessourceName(){
15
        return 'Registration';
16
    }
17
    public function getMandatoryFields()
18
    {
19
        return array('profile');
20
    }
21
22
    /**
23
     * Return with all the result from certain.
24
     * @return RegistrationCertain[]
25
     */
26 View Code Duplication
    public function getRegistrations($params = [])
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...
27
    {
28
        $request=  $this->get(null,$params);
29
        if($request->isSuccessFul()){
30
            $registrationCertainResults = $request->getResults();
31
            return $registrationCertainResults->registrations;
32
        }
33
        return null;
34
    }
35
    
36
    /**
37
     * Return with all the result from certain.
38
     * @return RegistrationCertain[]
39
     */
40 View Code Duplication
    public function getRegistrationsByEventCode($eventCode,$params = [])
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...
41
    {
42
        $request=  $this->get($eventCode,$params);
43
        if($request->isSuccessFul()){
44
            $registrationCertainResults = $request->getResults();
45
            return $registrationCertainResults->registrations;
46
        }
47
        return null;
48
    }
49
50
    /**
51
     * Return with all the result from certain.
52
     * @param string $eventCode eventCode
53
     * @param string $email email
54
     * @param boolean $returnRegCode To say if we want return a boolean or the regCode
55
     * @param string $orderBySecure in order to get the first registration when we have duplciates
56
     * @return registrationCode|null|boolean|[registrationCode=> "",attendeeTypeCode=>""]
0 ignored issues
show
Documentation introduced by
The doc-type registrationCode=>">registrationCode|null|boolean|[registrationCode=> could not be parsed: Unknown type name "[" at position 30. [(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...
57
     */
58
    public function hasRegistrationsByEventCodeAndEmail($eventCode,$email,$returnRegCode= true,$withAttenteeType=true,$orderBySecure='dateModified_asc')
59
    {
60
        $request=  $this->get($eventCode,[
61
            'email'=> $email,
62
            'orderBy'=> $orderBySecure
63
64
        ]);
65
        if($request->isSuccessFul()){
66
            $registrationCertainResults = $request->getResults();
67
            if($registrationCertainResults->size > 0 && $returnRegCode && $withAttenteeType){
68
                return [
69
                        'registrationCode' => $registrationCertainResults->registrations[0]->registrationCode,
70
                        'attendeeTypeCode' => (isset($registrationCertainResults->registrations[0]->attendeeTypeCode))?$registrationCertainResults->registrations[0]->attendeeTypeCode:'',
71
                    ];
72
            }
73
            elseif($registrationCertainResults->size > 0 && $returnRegCode){
74
                    return $registrationCertainResults->registrations[0]->registrationCode;
75
            } elseif($registrationCertainResults->size > 0  && !$returnRegCode){
76
                return true;
77
            }
78
        } elseif($request->isNotFound()){
79
            return false;
80
        }
81
        return null;
82
    }
83
84
    /**
85
     * Return with the result from certain.
86
     * @param string $eventCode
87
     * @param string $regCode
88
     * @return RegistrationObj
89
     */
90 View Code Duplication
    public function getRegistrationByEventCodeAnRegCode($eventCode,$regCode)
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...
91
    {
92
        $request=  $this->get($eventCode.'/'.$regCode);
93
        if($request->isSuccessFul()){
94
            $registrationCertainResult= $request->getResults();
95
            return $registrationCertainResult;
96
        }
97
        return null;
98
    }
99
100
    /**
101
     * Update with the result from certain.
102
     * @param string $eventCode
103
     * @param string $regCode
104
     * @return RegistrationObj
105
     */
106 View Code Duplication
    public function updateRegistrationByEventCodeAnRegCode($eventCode,$regCode,$data=[])
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...
107
    {
108
        $request=  $this->post($data,[],$eventCode.'/'.$regCode);
109
        if($request->isSuccessFul()){
110
            $registrationCertainResult= $request->getResults();
111
            return $registrationCertainResult;
112
        }
113
        return null;
114
    }
115
116
//    public function substituateRegistration($eventCode,$regCode,$profilePin){
117
//        return $this->updateRegistrationByEventCodeAnRegCode($eventCode, $regCode, [
118
//            'profile' => [
119
//                'pin'=> $profilePin
120
//            ]
121
//        ]);
122
//    }
123
}