<commit_before><?php

final class PhabricatorOwnersPackagePHIDType extends PhabricatorPHIDType {

  const TYPECONST = 'OPKG';

  public function getTypeName() {
    return pht('Owners Package');
  }

  public function getTypeIcon() {
    return 'fa-list-alt';
  }

  public function newObject() {
    return new PhabricatorOwnersPackage();
  }

  public function getPHIDTypeApplicationClass() {
    return 'PhabricatorOwnersApplication';
  }

  protected function buildQueryForObjects(
    PhabricatorObjectQuery $query,
    array $phids) {

    return id(new PhabricatorOwnersPackageQuery())
      ->withPHIDs($phids);
  }

  public function loadHandles(
    PhabricatorHandleQuery $query,
    array $handles,
    array $objects) {

    foreach ($handles as $phid => $handle) {
      $package = $objects[$phid];

      $monogram = $package->getMonogram();
      $name = $package->getName();
      $id = $package->getID();
      $uri = $package->getURI();

      $handle
        ->setName($monogram)
        ->setFullName("{$monogram}: {$name}")
        ->setCommandLineObjectName("{$monogram} {$name}")
        ->setURI($uri);

      if ($package->isArchived()) {
        $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
      }
    }
  }

  public function canLoadNamedObject($name) {
    return preg_match('/^O\d*[1-9]\d*$/i', $name);
  }

  public function loadNamedObjects(
    PhabricatorObjectQuery $query,
    array $names) {

    $id_map = array();
    foreach ($names as $name) {
      $id = (int)substr($name, 1);
      $id_map[$id][] = $name;
    }

    $objects = id(new PhabricatorOwnersPackageQuery())
      ->setViewer($query->getViewer())
      ->withIDs(array_keys($id_map))
      ->execute();

    $results = array();
    foreach ($objects as $id => $object) {
      foreach (idx($id_map, $id, array()) as $name) {
        $results[$name] = $object;
      }
    }

    return $results;
  }

}
<commit_msg>Use "fa-shopping-bag" instead of "fa-list-alt" for Owners package icon<commit_after><?php

final class PhabricatorOwnersPackagePHIDType extends PhabricatorPHIDType {

  const TYPECONST = 'OPKG';

  public function getTypeName() {
    return pht('Owners Package');
  }

  public function getTypeIcon() {
    return 'fa-shopping-bag';
  }

  public function newObject() {
    return new PhabricatorOwnersPackage();
  }

  public function getPHIDTypeApplicationClass() {
    return 'PhabricatorOwnersApplication';
  }

  protected function buildQueryForObjects(
    PhabricatorObjectQuery $query,
    array $phids) {

    return id(new PhabricatorOwnersPackageQuery())
      ->withPHIDs($phids);
  }

  public function loadHandles(
    PhabricatorHandleQuery $query,
    array $handles,
    array $objects) {

    foreach ($handles as $phid => $handle) {
      $package = $objects[$phid];

      $monogram = $package->getMonogram();
      $name = $package->getName();
      $id = $package->getID();
      $uri = $package->getURI();

      $handle
        ->setName($monogram)
        ->setFullName("{$monogram}: {$name}")
        ->setCommandLineObjectName("{$monogram} {$name}")
        ->setURI($uri);

      if ($package->isArchived()) {
        $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
      }
    }
  }

  public function canLoadNamedObject($name) {
    return preg_match('/^O\d*[1-9]\d*$/i', $name);
  }

  public function loadNamedObjects(
    PhabricatorObjectQuery $query,
    array $names) {

    $id_map = array();
    foreach ($names as $name) {
      $id = (int)substr($name, 1);
      $id_map[$id][] = $name;
    }

    $objects = id(new PhabricatorOwnersPackageQuery())
      ->setViewer($query->getViewer())
      ->withIDs(array_keys($id_map))
      ->execute();

    $results = array();
    foreach ($objects as $id => $object) {
      foreach (idx($id_map, $id, array()) as $name) {
        $results[$name] = $object;
      }
    }

    return $results;
  }

}

{'fraction_non_alphanumeric': 0.15110658865428644, 'fraction_numerical': 0.0015263291783261257, 'mean_word_length': 3.066184074457084, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4740295', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1277, 'n_words': 254}