protected function classCanBeAdded( $class, $file, $mode, $inProgressAutoloadArray )
    {
        $addClass = true;
        $sameRepositoryConflict = false;
        $kernelRepositoryConflict = false;

        if ( empty( $this->existingAutoloadArrays[self::MODE_KERNEL] ) )
        {
            $this->logWarning( "No existing kernel override found. Please generate kernel autoloads first." );
        }

        switch( $mode )
        {
            case self::MODE_KERNEL:
                $sameRepositoryConflict = $this->classExistsInArray( $class, $mode, $file, $inProgressAutoloadArray, $mode );

                if ( $sameRepositoryConflict )
                {
                    $addClass = false;
                }
                break;

            case self::MODE_EXTENSION:
            case self::MODE_TESTS:
            case self::MODE_SINGLE_EXTENSION:
                $kernelRepositoryConflict = $this->classExistsInArray( $class, self::MODE_KERNEL, $file, null, $mode  );
                $sameRepositoryConflict = $this->classExistsInArray( $class, $mode, $file, $inProgressAutoloadArray, $mode );

                if ( $kernelRepositoryConflict or $sameRepositoryConflict )
                {
                    $addClass = false;
                }
                break;

            case self::MODE_KERNEL_OVERRIDE:
                // For kernel overrides we only want class name collisions in
                // the kernel array to trigger a addClass hit. However we
                // like to emit warnings about duplicateses found in the current
                // generated array. Only one class may be overriding a kernel
                // at a time.

                $kernelRepositoryConflict = $this->classExistsInArray( $class, self::MODE_KERNEL, $file, $inProgressAutoloadArray, $mode  );
                $sameRepositoryConflict = $this->classExistsInArray( $class, $mode, $file, $inProgressAutoloadArray, $mode );

                if ( ( $sameRepositoryConflict and !$kernelRepositoryConflict ) or
                     ( $sameRepositoryConflict and $kernelRepositoryConflict ) or
                     ( !$kernelRepositoryConflict and !$sameRepositoryConflict )
                   )
                {
                    $addClass = false;
                }
                break;
        }
        return $addClass;
    }