Code Duplication    Length = 32-33 lines in 2 locations

main/inc/lib/icalcreator/iCalcreator.class.php 2 locations

@@ 706-737 (lines=32) @@
703
     * @param mixed $arg2 optional, ordno if arg1 = component type
704
     * @return void
705
     */
706
    function deleteComponent( $arg1, $arg2=FALSE  ) {
707
        $argType = $index = null;
708
        if ( ctype_digit( (string) $arg1 )) {
709
            $argType = 'INDEX';
710
            $index   = (int) $arg1 - 1;
711
        }
712
        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
713
            $argType = strtolower( $arg1 );
714
            $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
715
        }
716
        $cix1dC = 0;
717
        foreach ( $this->components as $cix => $component) {
718
            if( empty( $component )) continue;
719
            unset( $component->propix );
720
            if(( 'INDEX' == $argType ) && ( $index == $cix )) {
721
                unset( $this->components[$cix] );
722
                return TRUE;
723
            }
724
            elseif( $argType == $component->objName ) {
725
                if( $index == $cix1dC ) {
726
                    unset( $this->components[$cix] );
727
                    return TRUE;
728
                }
729
                $cix1dC++;
730
            }
731
            elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
732
                unset( $this->components[$cix] );
733
                return TRUE;
734
            }
735
        }
736
        return FALSE;
737
    }
738
    /**
739
     * get calendar component from container
740
     *
@@ 6616-6648 (lines=33) @@
6613
     * @param mixed $arg2 optional, ordno if arg1 = component type
6614
     * @return void
6615
     */
6616
    function deleteComponent( $arg1, $arg2=FALSE  ) {
6617
        if( !isset( $this->components )) return FALSE;
6618
        $argType = $index = null;
6619
        if ( ctype_digit( (string) $arg1 )) {
6620
            $argType = 'INDEX';
6621
            $index   = (int) $arg1 - 1;
6622
        }
6623
        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6624
            $argType = strtolower( $arg1 );
6625
            $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6626
        }
6627
        $cix2dC = 0;
6628
        foreach ( $this->components as $cix => $component) {
6629
            if( empty( $component )) continue;
6630
            unset( $component->propix );
6631
            if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6632
                unset( $this->components[$cix] );
6633
                return TRUE;
6634
            }
6635
            elseif( $argType == $component->objName ) {
6636
                if( $index == $cix2dC ) {
6637
                    unset( $this->components[$cix] );
6638
                    return TRUE;
6639
                }
6640
                $cix2dC++;
6641
            }
6642
            elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6643
                unset( $this->components[$cix] );
6644
                return TRUE;
6645
            }
6646
        }
6647
        return FALSE;
6648
    }
6649
    /**
6650
     * get calendar component subcomponent from component container
6651
     *