private function filterDiffs($compRes)
    {
        $result = [];

        if (is_array($this->config['updateTypes'])) {
            $updateActions = $this->config['updateTypes'];
        } else {
            $updateActions = array_map('trim', explode(',', $this->config['updateTypes']));
        }

        $allowedActions = ['create', 'drop', 'add', 'remove', 'modify'];
        $updateActions = array_intersect($updateActions, $allowedActions);

        foreach ($compRes as $table => $info) {
            if ($info['sourceOrphan']) {
                if (in_array('create', $updateActions)) {
                    $result[$table] = $info;
                }
            } elseif ($info['destOrphan']) {
                if (in_array('drop', $updateActions)) {
                    $result[$table] = $info;
                }
            } elseif ($info['differs']) {
                $resultInfo = $info;
                unset($resultInfo['differs']);

                foreach ($info['differs'] as $diff) {
                    if (empty($diff['dest']) && in_array('add', $updateActions)) {
                        $resultInfo['differs'][] = $diff;
                    } elseif (empty($diff['source']) && in_array('remove', $updateActions)) {
                        $resultInfo['differs'][] = $diff;
                    } elseif (in_array('modify', $updateActions)) {
                        $resultInfo['differs'][] = $diff;
                    }
                }

                if (!empty($resultInfo['differs'])) {
                    $result[$table] = $resultInfo;
                }
            }
        }
        return $result;
    }
private function filterDiffs($compRes)
    {
        $result = [];

        if (is_array($this->config['updateTypes'])) {
            $updateActions = $this->config['updateTypes'];
        } else {
            $updateActions = array_map('trim', explode(',', $this->config['updateTypes']));
        }

        $allowedActions = ['create', 'drop', 'add', 'remove', 'modify'];
        $updateActions = array_intersect($updateActions, $allowedActions);

        foreach ($compRes as $table => $info) {
            if ($info['sourceOrphan']) {
                if (in_array('create', $updateActions)) {
                    $result[$table] = $info;
                }
            } elseif ($info['destOrphan']) {
                if (in_array('drop', $updateActions)) {
                    $result[$table] = $info;
                }
            } elseif ($info['differs']) {
                $resultInfo = $info;
                unset($resultInfo['differs']);

                foreach ($info['differs'] as $diff) {
                    if (empty($diff['dest']) && in_array('add', $updateActions)) {
                        $resultInfo['differs'][] = $diff;
                    } elseif (empty($diff['source']) && in_array('remove', $updateActions)) {
                        $resultInfo['differs'][] = $diff;
                    } elseif (in_array('modify', $updateActions)) {
                        $resultInfo['differs'][] = $diff;
                    }
                }

                if (!empty($resultInfo['differs'])) {
                    $result[$table] = $resultInfo;
                }
            }
        }
        return $result;
    }
private function filterDiffs ( $ compRes ) { $ result = [ ] ; if ( is_array ( $ this -> config [ 'updateTypes' ] ) ) { $ updateActions = $ this -> config [ 'updateTypes' ] ; } else { $ updateActions = array_map ( 'trim' , explode ( ',' , $ this -> config [ 'updateTypes' ] ) ) ; } $ allowedActions = [ 'create' , 'drop' , 'add' , 'remove' , 'modify' ] ; $ updateActions = array_intersect ( $ updateActions , $ allowedActions ) ; foreach ( $ compRes as $ table => $ info ) { if ( $ info [ 'sourceOrphan' ] ) { if ( in_array ( 'create' , $ updateActions ) ) { $ result [ $ table ] = $ info ; } } elseif ( $ info [ 'destOrphan' ] ) { if ( in_array ( 'drop' , $ updateActions ) ) { $ result [ $ table ] = $ info ; } } elseif ( $ info [ 'differs' ] ) { $ resultInfo = $ info ; unset ( $ resultInfo [ 'differs' ] ) ; foreach ( $ info [ 'differs' ] as $ diff ) { if ( empty ( $ diff [ 'dest' ] ) && in_array ( 'add' , $ updateActions ) ) { $ resultInfo [ 'differs' ] [ ] = $ diff ; } elseif ( empty ( $ diff [ 'source' ] ) && in_array ( 'remove' , $ updateActions ) ) { $ resultInfo [ 'differs' ] [ ] = $ diff ; } elseif ( in_array ( 'modify' , $ updateActions ) ) { $ resultInfo [ 'differs' ] [ ] = $ diff ; } } if ( ! empty ( $ resultInfo [ 'differs' ] ) ) { $ result [ $ table ] = $ resultInfo ; } } } return $ result ; }
Filters comparison result and lefts only sync actions allowed by 'updateTypes' option
@param array $compRes
@return array
Filters comparison result and lefts only sync actions allowed by updateTypes option