CoreFiles by mySites.guru
UpdateOperation.php57 lines, 1,759 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
dc9c9cbe2920fa3654ddfa0e451571da
sha1
95c61a67ace4de6eb3c02acda543144e671bd4a3
sha256
dd8786745d10060627e02bedfd8e94ba7316d856683cb7bdf65c891779016a22
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Ldap\Adapter\ExtLdap;

use Symfony\Component\Ldap\Exception\UpdateOperationException;

class UpdateOperation
{
    private $operationType;
    private $values;
    private $attribute;

    private $validOperationTypes = [
        LDAP_MODIFY_BATCH_ADD,
        LDAP_MODIFY_BATCH_REMOVE,
        LDAP_MODIFY_BATCH_REMOVE_ALL,
        LDAP_MODIFY_BATCH_REPLACE,
    ];

    /**
     * @param int    $operationType An LDAP_MODIFY_BATCH_* constant
     * @param string $attribute     The attribute to batch modify on
     *
     * @throws UpdateOperationException on consistency errors during construction
     */
    public function __construct(int $operationType, string $attribute, ?array $values)
    {
        if (!\in_array($operationType, $this->validOperationTypes, true)) {
            throw new UpdateOperationException(sprintf('"%s" is not a valid modification type.', $operationType));
        }
        if (LDAP_MODIFY_BATCH_REMOVE_ALL === $operationType && null !== $values) {
            throw new UpdateOperationException(sprintf('$values must be null for LDAP_MODIFY_BATCH_REMOVE_ALL operation, "%s" given.', get_debug_type($values)));
        }

        $this->operationType = $operationType;
        $this->attribute = $attribute;
        $this->values = $values;
    }

    public function toArray(): array
    {
        return [
            'attrib' => $this->attribute,
            'modtype' => $this->operationType,
            'values' => $this->values,
        ];
    }
}

The same content is in 2 releases, Joomla 4.0.0-beta4 to 4.0.0-beta5. See them all, or every version of this file.