CoreFiles by mySites.guru
UpdateOperation.php57 lines, 1,736 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
bbbe4bdffb98816873e75034a3700093
sha1
cada3af3a5412ba9ccdf2cd1501ee532619372ab
sha256
4df95653bb28e14fb4d578c8a22ab953b7e37762fb551c0e4a32d0b8d037c585
<?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 const VALID_OPERATION_TYPES = [
        \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(
        private int $operationType,
        private string $attribute,
        private ?array $values,
    ) {
        if (!\in_array($operationType, self::VALID_OPERATION_TYPES, 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)));
        }
    }

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

        if (\LDAP_MODIFY_BATCH_REMOVE_ALL !== $this->operationType) {
            $op['values'] = $this->values;
        }

        return $op;
    }
}

The same content is in 49 releases, Joomla 6.0.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.