Example #1
0
 /**
  * Sample Requests.
  *
  * <code>
  *  $options = [
  *      // set random paremeters.
  *      'min'           => int,
  *      'max'           => int,
  *      // flags to pass to enable.
  *      'enableFlags'   => int,
  *      // options to pass to enable.
  *      'enableOptions' => []
  *  ];
  *
  * @param ProfilerInterface $profiler
  * @param int               $min
  * @param int               $max
  * @param array             $options
  */
 public function __construct(ProfilerInterface $profiler, int $min = self::MIN, int $max = self::MAX, array $options = [])
 {
     $this->profiler = $profiler;
     if ($this->shouldRun($min, $max)) {
         $eFlags = array_key_exists('enableFlags', $options) ? $options['enableFlags'] : null;
         $eOptions = array_key_exists('enableOptions', $options) ? $options['enableOptions'] : [];
         $this->profiler->enable($eFlags, $eOptions);
         register_shutdown_function(function () use($profiler) {
             $profiler->disable();
             $profiler->save();
         });
     }
 }
 /**
  * @covers Profiler::simplifyUrl
  */
 public function testSimplifyUrl()
 {
     $this->profiler->setNormalizeUrls(self::NormalizeUrls);
     $this->assertSame(array_values(self::NormalizeUrls)[0], $this->profiler->simplifyUrl('foo/'));
 }