Code Duplication    Length = 35-35 lines in 2 locations

src/Observers/GenericValidationObserver.php 1 location

@@ 108-142 (lines=35) @@
105
     *
106
     * @return array The processed row
107
     */
108
    protected function process()
109
    {
110
111
        // load the available header names
112
        $headerNames = array_keys($this->getHeaders());
113
114
        // iterate over the custom validations
115
        foreach ($headerNames as $headerName) {
116
            // load the attribute value from the row
117
            $attributeValue = $this->getValue($headerName);
118
            // reverse map the header name to the original column name
119
            $columnName = $this->reverseMapHeaderNameToColumnName($headerName);
120
            // load the callbacks for the actual attribute code
121
            $callbacks = $this->getCallbacksByType($columnName);
122
            // invoke the registered callbacks
123
            foreach ($callbacks as $callback) {
124
                try {
125
                    $callback->handle($columnName, $attributeValue);
126
                } catch (\InvalidArgumentException $iea) {
127
                    // add the the validation result to the status
128
                    $this->mergeStatus(
129
                        array(
130
                            RegistryKeys::VALIDATIONS => array(
131
                                basename($this->getFilename()) => array(
132
                                    $this->getSubject()->getLineNumber() => array(
133
                                        $columnName => $iea->getMessage()
134
                                    )
135
                                )
136
                            )
137
                        )
138
                    );
139
                }
140
            }
141
        }
142
    }
143
144
    /**
145
     * Reverse map the passed header name, to the original column name.

src/Observers/GenericValidatorObserver.php 1 location

@@ 85-119 (lines=35) @@
82
     *
83
     * @return array The processed row
84
     */
85
    protected function process()
86
    {
87
88
        // load the available header names
89
        $headerNames = array_keys($this->getHeaders());
90
91
        // iterate over the custom validations
92
        foreach ($headerNames as $headerName) {
93
            // map the header name to the attribute code, if an mapping is available
94
            $attributeCode = $this->mapAttributeCodeByHeaderMapping($headerName);
95
            // load the attribute value from the row
96
            $attributeValue = $this->getValue($attributeCode);
97
            // load the callbacks for the actual attribute code
98
            $callbacks = $this->getCallbacksByType($attributeCode);
99
            // invoke the registered callbacks
100
            foreach ($callbacks as $callback) {
101
                try {
102
                    $callback->handle($attributeCode, $attributeValue);
103
                } catch (\InvalidArgumentException $iea) {
104
                    // add the the validation result to the status
105
                    $this->mergeStatus(
106
                        array(
107
                            RegistryKeys::VALIDATIONS => array(
108
                                basename($this->getFilename()) => array(
109
                                    $this->getSubject()->getLineNumber() => array(
110
                                        $attributeCode => $iea->getMessage()
111
                                    )
112
                                )
113
                            )
114
                        )
115
                    );
116
                }
117
            }
118
        }
119
    }
120
121
    /**
122
     * Map the passed attribute code, if a header mapping exists and return the