public static function checkSymlink($symlinkTarget, $symlinkName, $forceSymlink = false)
    {
        if ($forceSymlink && file_exists($symlinkName) && !is_link($symlinkName)) {
            if ('link' !== filetype($symlinkName)) {
                throw new \UnexpectedValueException("{$symlinkName} exists and is not a link");
            }
        } elseif (is_link($symlinkName)) {
            $linkTarget = readlink($symlinkName);
            if ($linkTarget !== $symlinkTarget) {
                if (!$forceSymlink) {
                    throw new \UnexpectedValueException(
                        "Symlink '{$symlinkName}' points to '{$linkTarget}' instead of '{$symlinkTarget}'"
                    );
                }
                unlink($symlinkName);

                return false;
            }

            return true;
        }

        return false;
    }
public static function checkSymlink($symlinkTarget, $symlinkName, $forceSymlink = false)
    {
        if ($forceSymlink && file_exists($symlinkName) && !is_link($symlinkName)) {
            if ('link' !== filetype($symlinkName)) {
                throw new \UnexpectedValueException("{$symlinkName} exists and is not a link");
            }
        } elseif (is_link($symlinkName)) {
            $linkTarget = readlink($symlinkName);
            if ($linkTarget !== $symlinkTarget) {
                if (!$forceSymlink) {
                    throw new \UnexpectedValueException(
                        "Symlink '{$symlinkName}' points to '{$linkTarget}' instead of '{$symlinkTarget}'"
                    );
                }
                unlink($symlinkName);

                return false;
            }

            return true;
        }

        return false;
    }
public static function checkSymlink ( $ symlinkTarget , $ symlinkName , $ forceSymlink = false ) { if ( $ forceSymlink && file_exists ( $ symlinkName ) && ! is_link ( $ symlinkName ) ) { if ( 'link' !== filetype ( $ symlinkName ) ) { throw new \ UnexpectedValueException ( "{$symlinkName} exists and is not a link" ) ; } } elseif ( is_link ( $ symlinkName ) ) { $ linkTarget = readlink ( $ symlinkName ) ; if ( $ linkTarget !== $ symlinkTarget ) { if ( ! $ forceSymlink ) { throw new \ UnexpectedValueException ( "Symlink '{$symlinkName}' points to '{$linkTarget}' instead of '{$symlinkTarget}'" ) ; } unlink ( $ symlinkName ) ; return false ; } return true ; } return false ; }
Checks symlink's existence.

@param string $symlinkTarget The Target
@param string $symlinkName   The Name
@param boolean $forceSymlink Force to be a link or throw exception

@return boolean
@throws \Exception
Checks symlink s existence .