Completed
Push — master ( 3d3926...3792f2 )
by Raphaël
02:26
created

RegistrationCertain::getMandatoryFields()   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
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)
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);
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
57
     */
58
    public function hasRegistrationsByEventCodeAndEmail($eventCode,$email,$returnRegCode= 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){
68
                    return $registrationCertainResults->registrations[0];
69
            } elseif($registrationCertainResults->size > 0  && !$returnRegCode){
70
                return true;
71
            }
72
        } elseif($request->isNotFound()){
73
            return false;
74
        }
75
        return null;
76
    }
77
78
    /**
79
     * Return with the result from certain.
80
     * @param string $eventCode
81
     * @param string $regCode
82
     * @return RegistrationObj
83
     */
84 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...
85
    {
86
        $request=  $this->get($eventCode.'/'.$regCode);
87
        if($request->isSuccessFul()){
88
            $registrationCertainResult= $request->getResults();
89
            return $registrationCertainResult;
90
        }
91
        return null;
92
    }
93
94
    /**
95
     * Update with the result from certain.
96
     * @param string $eventCode
97
     * @param string $regCode
98
     * @return RegistrationObj
99
     */
100 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...
101
    {
102
        $request=  $this->post($data,[],$eventCode.'/'.$regCode);
103
        if($request->isSuccessFul()){
104
            $registrationCertainResult= $request->getResults();
105
            return $registrationCertainResult;
106
        }
107
        return null;
108
    }
109
110
//    public function substituateRegistration($eventCode,$regCode,$profilePin){
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
111
//        return $this->updateRegistrationByEventCodeAnRegCode($eventCode, $regCode, [
112
//            'profile' => [
113
//                'pin'=> $profilePin
114
//            ]
115
//        ]);
116
//    }
117
}