Ejemplo n.º 1
0
 /**
  * @param string $name
  * @return object[]
  */
 public function samples($name)
 {
     if (!isset($this->samples[$name])) {
         $builder = $this->retrieve($name);
         $this->samples[$name] = $this->sampler->samples($builder, $this->counts[$name]);
     }
     return $this->samples[$name];
 }
Ejemplo n.º 2
0
 /**
  * @param string|Builder $builder
  * @param callback       $callback
  * @return null|array|object
  */
 public function matchingSample($builder, $callback)
 {
     if (is_string($builder) && !$this->getLinkManager()->hasUnlimitedSamples($builder)) {
         foreach ($this->getLinkManager()->samples($builder) as $sample) {
             if ($callback($sample)) {
                 return $sample;
             }
         }
         return null;
     } else {
         if (!$builder instanceof Builder) {
             $builder = $this->retrieve($builder);
         }
         $tries = $this->sampler->getUniqueTries();
         for ($i = 0; $i < $tries; $i++) {
             $sample = $this->sampler->sample($builder);
             if ($callback($sample)) {
                 return $sample;
             }
         }
         return null;
     }
 }