<?php
namespace nulib\ldap\io;

use nulib\file;
use nulib\file\IWriter;
use nulib\ldap\LdapObject;

abstract class LdapWriter {
  static function write_object($output, LdapObject $object, ?array $names=null): void {
    $writer = new static($output);
    $writer->write($object, $names);
    $writer->close();
  }

  function __construct($output=null) {
    $this->writer = file::writer($output);
  }

  /** @var IWriter  */
  protected $writer;

  function close(): void {
    $this->writer->close();
  }
}
