CoreFiles by mySites.guru
EvolvableLinkProviderTrait.php40 lines, 797 bytes, from Joomla_4.3.4-Stable-Full_Package.zip
Raw History Compare with 4.3.3
md5
861e3979b2314bc559111422eff7e671
sha1
73ecf47c2e60f6d86877564872aeecb4c4496836
sha256
32e2263d88ad00f60bed59eb78cdc841e4f5b8eb16b94268fb42c7649ebecd57
<?php

namespace Fig\Link;

use Psr\Link\LinkInterface;
use Psr\Link\EvolvableLinkProviderInterface;

/**
 * Class EvolvableLinkProviderTrait
 *
 * @implements EvolvableLinkProviderInterface
 */
trait EvolvableLinkProviderTrait
{
    use LinkProviderTrait;

    /**
     * {@inheritdoc}
     */
    public function withLink(LinkInterface $link)
    {
        $that = clone($this);
        $splosh = spl_object_hash($link);
        if (!array_key_exists($splosh, $that->links)) {
            $that->links[$splosh] = $link;
        }
        return $that;
    }

    /**
     * {@inheritdoc}
     */
    public function withoutLink(LinkInterface $link)
    {
        $that = clone($this);
        $splosh = spl_object_hash($link);
        unset($that->links[$splosh]);
        return $that;
    }
}

The same content is in 141 releases, Joomla 4.0.0-alpha2 to 4.4.14. See them all, or every version of this file.