public function toLdap()
{
foreach ($this->batches as $index => $batch) {
/** @var Batch $batch */
if (!$this->batches->has($index)) {
continue;
} elseif (!$this->schema->hasConverter($batch->getAttribute())) {
$batch->setValues($this->encodeValues($batch->getValues()));
} else {
$this->currentBatchIndex = $index;
$batch->setValues($this->getConvertedValues($batch->getValues(), $batch->getAttribute(), 'toLdap'));
if (in_array($batch->getAttribute(), $this->aggregated)) {
$batch->setAttribute($this->schema->getAttributeToLdap($batch->getAttribute()));
} elseif (in_array($batch->getAttribute(), $this->remove)) {
$this->batches->remove($index);
}
}
}
return $this->batches;
}