<commit_before><?php

namespace Donquixote\Nicetrace\BacktraceToNicetrace;

use Donquixote\Nicetrace\CallToNicecall\CallToNicecall_Class;
use Donquixote\Nicetrace\CallToNicecall\CallToNicecall_FileWithLine;
use Donquixote\Nicetrace\CallToNicecall\CallToNicecall_MultipleCombined;
use Donquixote\Nicetrace\CallToNicecall\CallToNicecall_NamedArgs;
use Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface;
use Donquixote\Nicetrace\CallToShortname\CallToShortname_Full;
use Donquixote\Nicetrace\CallToShortname\CallToShortname_NoNamespace;
use Donquixote\Nicetrace\CallToShortname\CallToShortnameInterface;
use Donquixote\Nicetrace\PathShortener\PathShortener_BasePaths;
use Donquixote\Nicetrace\PathShortener\PathShortener_Passthru;
use Donquixote\Nicetrace\PathShortener\PathShortenerInterface;

class BacktraceToNicetrace implements BacktraceToNicetraceInterface {

  /**
   * @var \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface
   */
  private $innerCallToNicecall;

  /**
   * @var \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface
   */
  private $outerCallToNicecall;

  /**
   * @var \Donquixote\Nicetrace\CallToShortname\CallToShortnameInterface
   */
  private $callToShortname;

  /**
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function createPassthru() {
    return self::create(new PathShortener_Passthru());
  }

  /**
   * @param string[] $basePaths
   *
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function createWithBasePaths(array $basePaths = array()) {
    $pathShortener = (array() === $basePaths)
      ? new PathShortener_Passthru()
      : new PathShortener_BasePaths($basePaths);
    return self::create($pathShortener);
  }

  /**
   * @param \Donquixote\Nicetrace\PathShortener\PathShortenerInterface $pathShortener
   *
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function create(PathShortenerInterface $pathShortener) {
    return new self(
      new CallToNicecall_FileWithLine($pathShortener),
      new CallToNicecall_NamedArgs(),
      new CallToShortname_Full());
  }

  /**
   * @param \Donquixote\Nicetrace\PathShortener\PathShortenerInterface $pathShortener
   *
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function createWithNamespacelessKey(PathShortenerInterface $pathShortener) {
    return new self(
      new CallToNicecall_MultipleCombined(array(
        new CallToNicecall_FileWithLine($pathShortener),
        new CallToNicecall_Class(),
      )),
      new CallToNicecall_NamedArgs(),
      new CallToShortname_NoNamespace());
  }

  /**
   * @param \Donquixote\Nicetrace\PathShortener\PathShortenerInterface $pathShortener
   *
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function createWithClasslessKey(PathShortenerInterface $pathShortener) {
    return new self(
      new CallToNicecall_MultipleCombined(array(
        new CallToNicecall_FileWithLine($pathShortener),
        new CallToNicecall_Class(),
      )),
      new CallToNicecall_NamedArgs(),
      new CallToShortname_NoNamespace());
  }

  /**
   * @param \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface $innerCallToNicecall
   * @param \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface $outerCallToNicecall
   * @param \Donquixote\Nicetrace\CallToShortname\CallToShortnameInterface $callToShortname
   */
  function __construct(CallToNicecallInterface $innerCallToNicecall, CallToNicecallInterface $outerCallToNicecall, CallToShortnameInterface $callToShortname) {
    $this->innerCallToNicecall = $innerCallToNicecall;
    $this->outerCallToNicecall = $outerCallToNicecall;
    $this->callToShortname = $callToShortname;
  }

  /**
   * @param array $backtrace
   *   A backtrace, as obtained with debug_backtrace().
   *
   * @return array
   *
   * @see debug_backtrace()
   */
  function backtraceGetNicetrace(array $backtrace) {
<commit_msg>Thin out static factories. People should use the Builder instead.<commit_after><?php

namespace Donquixote\Nicetrace\BacktraceToNicetrace;

use Donquixote\Nicetrace\CallToNicecall\CallToNicecall_FileWithLine;
use Donquixote\Nicetrace\CallToNicecall\CallToNicecall_NamedArgs;
use Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface;
use Donquixote\Nicetrace\CallToShortname\CallToShortname_Full;
use Donquixote\Nicetrace\CallToShortname\CallToShortnameInterface;
use Donquixote\Nicetrace\PathShortener\PathShortener_BasePaths;
use Donquixote\Nicetrace\PathShortener\PathShortener_Passthru;
use Donquixote\Nicetrace\PathShortener\PathShortenerInterface;

class BacktraceToNicetrace implements BacktraceToNicetraceInterface {

  /**
   * @var \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface
   */
  private $innerCallToNicecall;

  /**
   * @var \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface
   */
  private $outerCallToNicecall;

  /**
   * @var \Donquixote\Nicetrace\CallToShortname\CallToShortnameInterface
   */
  private $callToShortname;

  /**
   * @param string[] $basePaths
   *
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function createWithBasePaths(array $basePaths = array()) {
    $pathShortener = (array() === $basePaths)
      ? new PathShortener_Passthru()
      : new PathShortener_BasePaths($basePaths);
    return self::createWithPathShortener($pathShortener);
  }

  /**
   * @param \Donquixote\Nicetrace\PathShortener\PathShortenerInterface $pathShortener
   *
   * @return \Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceInterface
   */
  static function createWithPathShortener(PathShortenerInterface $pathShortener) {
    return new self(
      new CallToNicecall_FileWithLine($pathShortener),
      new CallToNicecall_NamedArgs(),
      new CallToShortname_Full());
  }

  /**
   * @param \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface $innerCallToNicecall
   * @param \Donquixote\Nicetrace\CallToNicecall\CallToNicecallInterface $outerCallToNicecall
   * @param \Donquixote\Nicetrace\CallToShortname\CallToShortnameInterface $callToShortname
   */
  function __construct(CallToNicecallInterface $innerCallToNicecall, CallToNicecallInterface $outerCallToNicecall, CallToShortnameInterface $callToShortname) {
    $this->innerCallToNicecall = $innerCallToNicecall;
    $this->outerCallToNicecall = $outerCallToNicecall;
    $this->callToShortname = $callToShortname;
  }

  /**
   * @param array $backtrace
   *   A backtrace, as obtained with debug_backtrace().
   *
   * @return array
   *
   * @see debug_backtrace()
   */
  function backtraceGetNicetrace(array $backtrace) {

{'fraction_non_alphanumeric': 0.08941659337437702, 'fraction_numerical': 0.0, 'mean_word_length': 5.231050228310503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2645027', 'n_tokens_mistral': 2366, 'n_tokens_neox': 2206, 'n_words': 287}