Config::listOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace Rollbar;
2
3
use Rollbar\Payload\Level;
4
use Rollbar\Payload\Payload;
5
use \Rollbar\Payload\EncodedPayload;
6
7
if (!defined('ROLLBAR_INCLUDED_ERRNO_BITMASK')) {
8
    define(
9
        'ROLLBAR_INCLUDED_ERRNO_BITMASK',
10
        E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR
11
    );
12
}
13
14
class Config
15
{
16
    private static $options = array(
17
        'access_token',
18
        'agent_log_location',
19
        'allow_exec',
20
        'endpoint',
21
        'base_api_url',
22
        'branch',
23
        'capture_error_stacktraces',
24
        'check_ignore',
25
        'code_version',
26
        'custom',
27
        'custom_data_method',
28
        'enabled',
29
        'environment',
30
        'error_sample_rates',
31
        'exception_sample_rates',
32
        'fluent_host',
33
        'fluent_port',
34
        'fluent_tag',
35
        'handler',
36
        'host',
37
        'include_error_code_context',
38
        'include_exception_code_context',
39
        'included_errno',
40
        'logger',
41
        'person',
42
        'person_fn',
43
        'capture_ip',
44
        'capture_username',
45
        'capture_email',
46
        'root',
47
        'scrub_fields',
48
        'scrub_whitelist',
49
        'timeout',
50
        'custom_truncation',
51
        'report_suppressed',
52
        'use_error_reporting',
53
        'proxy',
54
        'send_message_trace',
55
        'include_raw_request_body',
56
        'local_vars_dump',
57
        'verbosity'
58
    );
59
    
60
    private $accessToken;
61
    /**
62
     * @var string $enabled Enable / disable Rollbar SDK.
63
     */
64
    private $enabled = true;
65
    /**
66
     * @var DataBuilder
67
     */
68
    private $dataBuilder;
69
    private $configArray;
70
    
71
    /**
72
     * @var LevelFactory
73
     */
74
    private $levelFactory;
75
    
76
    /**
77
     * @var Utilities
78
     */
79
    private $utilities;
80
    
81
    /**
82
     * @var TransformerInterface
83
     */
84
    private $transformer;
85
    /**
86
     * @var FilterInterface
87
     */
88
    private $filter;
89
    private $minimumLevel;
90
    /**
91
     * @var ResponseHandlerInterface
92
     */
93
    private $responseHandler;
94
    /**
95
     * @var \Rollbar\Senders\SenderInterface
96
     */
97
    private $sender;
98
    private $reportSuppressed;
99
    /**
100
     * @var Scrubber
101
     */
102
    private $scrubber;
103
104
    private $batched = false;
105
    private $batchSize = 50;
106
107
    private $custom = array();
108
    
109
    /**
110
     * @var callable with parameters $toLog, $contextDataMethodContext. The return
111
     * value of the callable will be appended to the custom field of the item.
112
     */
113
    private $customDataMethod;
114
    
115
    /**
116
     * @var callable
117
     */
118
    private $checkIgnore;
119
    private $errorSampleRates;
120
    private $exceptionSampleRates;
121
    private $mtRandmax;
122
123
    private $includedErrno;
124
    private $useErrorReporting = false;
125
    
126
    /**
127
     * @var boolean Should debug_backtrace() data be sent with string messages
128
     * sent through RollbarLogger::log().
129
     */
130
    private $sendMessageTrace = false;
131
    
132
    /**
133
     * @var string (One of the \Psr\Log\LogLevel constants) How much debugging
134
     * info should be recorded in the Rollbar debug log file.
135
     * ($rollbarLogger->getDebugLogFile() => commonly /tmp/rollbar.debug.log.
136
     * Default: Psr\Log\LogLevel::ERROR
137
     */
138
    private $verbosity;
139
    
140
    /**
141
     * @var string (fully qualified class name) The name of the your custom
142
     * truncation strategy class. The class should inherit from
143
     * Rollbar\Truncation\AbstractStrategy.
144
     */
145
    private $customTruncation;
146
147
    public function __construct(array $configArray)
148
    {
149
        $this->verbosity = \Rollbar\Defaults::get()->verbosity();
150
        $this->includedErrno = \Rollbar\Defaults::get()->includedErrno();
151
        
152
        $this->levelFactory = new LevelFactory();
153
        $this->utilities = new Utilities();
154
        
155
        $this->updateConfig($configArray);
156
157
        $this->errorSampleRates = \Rollbar\Defaults::get()->errorSampleRates();
158
        if (isset($configArray['error_sample_rates'])) {
159
            $this->errorSampleRates = $configArray['error_sample_rates'];
160
        }
161
        
162
        $this->exceptionSampleRates = \Rollbar\Defaults::get()->exceptionSampleRates();
163
        if (isset($configArray['exception_sample_rates'])) {
164
            $this->exceptionSampleRates = $configArray['exception_sample_rates'];
165
        }
166
167
        $levels = array(E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING,
168
            E_USER_NOTICE, E_STRICT, E_RECOVERABLE_ERROR);
169
        // PHP 5.3.0
170
        if (defined('E_DEPRECATED')) {
171
            $levels = array_merge($levels, array(E_DEPRECATED, E_USER_DEPRECATED));
172
        }
173
        $curr = 1;
174
        for ($i = 0, $num = count($levels); $i < $num; $i++) {
175
            $level = $levels[$i];
176
            if (!isset($this->errorSampleRates[$level])) {
177
                $this->errorSampleRates[$level] = $curr;
178
            }
179
        }
180
        $this->mtRandmax = mt_getrandmax();
181
    }
182
    
183
    public static function listOptions()
184
    {
185
        return self::$options;
186
    }
187
188
    public function configure($config)
189
    {
190
        $this->updateConfig($this->extend($config));
191
    }
192
193
    public function extend($config)
194
    {
195
        return array_replace_recursive(array(), $this->configArray, $config);
196
    }
197
198
    public function getConfigArray()
199
    {
200
        return $this->configArray;
201
    }
202
203
    protected function updateConfig($config)
204
    {
205
        $this->configArray = $config;
206
207
        $this->setEnabled($config);
208
        $this->setAccessToken($config);
209
        $this->setDataBuilder($config);
210
        $this->setTransformer($config);
211
        $this->setMinimumLevel($config);
212
        $this->setReportSuppressed($config);
213
        $this->setFilters($config);
214
        $this->setSender($config);
215
        $this->setScrubber($config);
216
        $this->setBatched($config);
217
        $this->setBatchSize($config);
218
        $this->setCustom($config);
219
        $this->setResponseHandler($config);
220
        $this->setCheckIgnoreFunction($config);
221
        $this->setSendMessageTrace($config);
222
        $this->setVerbosity($config);
223
224
        if (isset($config['included_errno'])) {
225
            $this->includedErrno = $config['included_errno'];
226
        }
227
228
        $this->useErrorReporting = \Rollbar\Defaults::get()->useErrorReporting();
229
        if (isset($config['use_error_reporting'])) {
230
            $this->useErrorReporting = $config['use_error_reporting'];
231
        }
232
        
233
        if (isset($config['custom_truncation'])) {
234
            $this->customTruncation = $config['custom_truncation'];
235
        }
236
        
237
        $this->customDataMethod = \Rollbar\Defaults::get()->customDataMethod();
238
        if (isset($config['custom_data_method'])) {
239
            $this->customDataMethod = $config['custom_data_method'];
240
        }
241
    }
242
243
    private function setAccessToken($config)
244
    {
245
        if (isset($_ENV['ROLLBAR_ACCESS_TOKEN']) && !isset($config['access_token'])) {
246
            $config['access_token'] = $_ENV['ROLLBAR_ACCESS_TOKEN'];
247
        }
248
        $this->utilities->validateString($config['access_token'], "config['access_token']", 32, false);
249
        $this->accessToken = $config['access_token'];
250
    }
251
252
    private function setEnabled($config)
253
    {
254
        if (array_key_exists('enabled', $config) && $config['enabled'] === false) {
255
            $this->disable();
256
        } else {
257
            if (\Rollbar\Defaults::get()->enabled() === false) {
258
                $this->disable();
259
            } else {
260
                $this->enable();
261
            }
262
        }
263
    }
264
    
265
    public function enable()
266
    {
267
        $this->enabled = true;
0 ignored issues
show
Documentation Bug introduced by
The property $enabled was declared of type string, but true is of type true. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
268
    }
269
    
270
    public function disable()
271
    {
272
        $this->enabled = false;
0 ignored issues
show
Documentation Bug introduced by
The property $enabled was declared of type string, but false is of type false. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
273
    }
274
275
    private function setDataBuilder($config)
276
    {
277
        if (!isset($config['levelFactory'])) {
278
            $config['levelFactory'] = $this->levelFactory;
279
        }
280
        
281
        if (!isset($config['utilities'])) {
282
            $config['utilities'] = $this->utilities;
283
        }
284
        
285
        $exp = "Rollbar\DataBuilderInterface";
286
        $def = "Rollbar\DataBuilder";
287
        $this->setupWithOptions($config, "dataBuilder", $exp, $def, true);
288
    }
289
290
    private function setTransformer($config)
291
    {
292
        $expected = "Rollbar\TransformerInterface";
293
        $this->setupWithOptions($config, "transformer", $expected);
294
    }
295
296
    private function setMinimumLevel($config)
297
    {
298
        $this->minimumLevel = 0;
299
        if (empty($config['minimumLevel'])) {
300
            $this->minimumLevel = 0;
301
        } elseif ($config['minimumLevel'] instanceof Level) {
302
            $this->minimumLevel = $config['minimumLevel']->toInt();
303
        } elseif (is_string($config['minimumLevel'])) {
304
            $level = $this->levelFactory->fromName($config['minimumLevel']);
305
            if ($level !== null) {
306
                $this->minimumLevel = $level->toInt();
307
            }
308
        } elseif (is_int($config['minimumLevel'])) {
309
            $this->minimumLevel = $config['minimumLevel'];
310
        }
311
    }
312
313
    private function setReportSuppressed($config)
314
    {
315
        $this->reportSuppressed = isset($config['reportSuppressed']) && $config['reportSuppressed'];
316
        if (!isset($this->reportSuppressed)) {
317
            $this->reportSuppressed = isset($config['report_suppressed']) && $config['report_suppressed'];
318
        }
319
        
320
        if (!isset($this->reportSuppressed)) {
321
            $this->reportSuppressed = \Rollbar\Defaults::get()->reportSuppressed();
322
        }
323
    }
324
325
    private function setFilters($config)
326
    {
327
        $this->setupWithOptions($config, "filter", "Rollbar\FilterInterface");
328
    }
329
330
    private function setSender($config)
331
    {
332
        $expected = "Rollbar\Senders\SenderInterface";
333
        
334
        $default = "Rollbar\Senders\CurlSender";
335
336
        $this->setTransportOptions($config);
337
        $default = $this->setAgentSenderOptions($config, $default);
338
        $default = $this->setFluentSenderOptions($config, $default);
339
340
        $this->setupWithOptions($config, "sender", $expected, $default);
341
    }
342
343
    private function setScrubber($config)
344
    {
345
        $exp = "Rollbar\ScrubberInterface";
346
        $def = "Rollbar\Scrubber";
347
        $this->setupWithOptions($config, "scrubber", $exp, $def, true);
348
    }
349
350
    private function setBatched($config)
351
    {
352
        if (array_key_exists('batched', $config)) {
353
            $this->batched = $config['batched'];
354
        }
355
    }
356
357
    private function setBatchSize($config)
358
    {
359
        if (array_key_exists('batch_size', $config)) {
360
            $this->batchSize = $config['batch_size'];
361
        }
362
    }
363
364
    public function setCustom($config)
365
    {
366
        $this->dataBuilder->setCustom($config);
367
    }
368
    
369
    public function addCustom($key, $data)
370
    {
371
        $this->dataBuilder->addCustom($key, $data);
372
    }
373
    
374
    public function removeCustom($key)
375
    {
376
        $this->dataBuilder->removeCustom($key);
377
    }
378
    
379
    public function getCustom()
380
    {
381
        return $this->dataBuilder->getCustom();
382
    }
383
    
384
    public function setCustomTruncation($type)
385
    {
386
        $this->customTruncation = $type;
387
    }
388
    
389
    public function getCustomTruncation()
390
    {
391
        return $this->customTruncation;
392
    }
393
394
    private function setTransportOptions(&$config)
395
    {
396
        if (array_key_exists('base_api_url', $config)) {
397
            $config['senderOptions']['endpoint'] = $config['base_api_url'] . 'item/';
398
        }
399
400
        if (array_key_exists('endpoint', $config)) {
401
            $config['senderOptions']['endpoint'] = $config['endpoint'] . 'item/';
402
        }
403
404
        if (array_key_exists('timeout', $config)) {
405
            $config['senderOptions']['timeout'] = $config['timeout'];
406
        }
407
408
        if (array_key_exists('proxy', $config)) {
409
            $config['senderOptions']['proxy'] = $config['proxy'];
410
        }
411
412
        if (array_key_exists('ca_cert_path', $config)) {
413
            $config['senderOptions']['ca_cert_path'] = $config['ca_cert_path'];
414
        }
415
    }
416
417
    private function setAgentSenderOptions(&$config, $default)
418
    {
419
        if (!array_key_exists('handler', $config) || $config['handler'] != 'agent') {
420
            return $default;
421
        }
422
        $default = "Rollbar\Senders\AgentSender";
423
        if (array_key_exists('agent_log_location', $config)) {
424
            $config['senderOptions'] = array(
425
                'agentLogLocation' => $config['agent_log_location']
426
            );
427
        }
428
        return $default;
429
    }
430
431
    private function setFluentSenderOptions(&$config, $default)
432
    {
433
        if (!isset($config['handler']) || $config['handler'] != 'fluent') {
434
            return $default;
435
        }
436
        $default = "Rollbar\Senders\FluentSender";
437
438
        if (isset($config['fluent_host'])) {
439
            $config['senderOptions']['fluentHost'] = $config['fluent_host'];
440
        }
441
442
        if (isset($config['fluent_port'])) {
443
            $config['senderOptions']['fluentPort'] = $config['fluent_port'];
444
        }
445
446
        if (isset($config['fluent_tag'])) {
447
            $config['senderOptions']['fluentTag'] = $config['fluent_tag'];
448
        }
449
450
        return $default;
451
    }
452
453
    private function setResponseHandler($config)
454
    {
455
        $this->setupWithOptions($config, "responseHandler", "Rollbar\ResponseHandlerInterface");
456
    }
457
458
    private function setCheckIgnoreFunction($config)
459
    {
460
        // Remain backwards compatible
461
        if (isset($config['checkIgnore'])) {
462
            $this->checkIgnore = $config['checkIgnore'];
463
        }
464
        
465
        if (isset($config['check_ignore'])) {
466
            $this->checkIgnore = $config['check_ignore'];
467
        }
468
    }
469
470
    private function setSendMessageTrace($config)
471
    {
472
        if (!isset($config['send_message_trace'])) {
473
            return;
474
        }
475
476
        $this->sendMessageTrace = $config['send_message_trace'];
477
    }
478
    
479
    private function setVerbosity($config)
480
    {
481
        if (!isset($config['verbosity'])) {
482
            return;
483
        }
484
485
        $this->verbosity = $config['verbosity'];
486
    }
487
    
488
    public function getVerbosity()
489
    {
490
        return $this->verbosity;
491
    }
492
493
    /**
494
     * Allows setting up configuration options that might be specified by class
495
     * name. Any interface used with `setupWithOptions` should be constructed
496
     * with a single parameter: an associative array with the config options.
497
     * It is assumed that it will be in the configuration as a sibling to the
498
     * key the class is named in. The options should have the same key as the
499
     * classname, but with 'Options' appended. E.g:
500
     * ```array(
501
     *   "sender" => "MySender",
502
     *   "senderOptions" => array(
503
     *     "speed" => 11,
504
     *     "protocol" => "First Contact"
505
     *   )
506
     * );```
507
     * Will be initialized as if you'd used:
508
     * `new MySender(array("speed"=>11,"protocol"=>"First Contact"));`
509
     * You can also just pass an instance in directly. (In which case options
510
     * are ignored)
511
     * @param $config
512
     * @param $keyName
513
     * @param $expectedType
514
     * @param mixed $defaultClass
515
     * @param bool $passWholeConfig
516
     */
517
    protected function setupWithOptions(
518
        $config,
519
        $keyName,
520
        $expectedType,
521
        $defaultClass = null,
522
        $passWholeConfig = false
523
    ) {
524
525
        $$keyName = isset($config[$keyName]) ? $config[$keyName] : null;
526
527
        if (is_null($defaultClass) && is_null($$keyName)) {
528
            return;
529
        }
530
531
        if (is_null($$keyName)) {
532
            $$keyName = $defaultClass;
533
        }
534
        if (is_string($$keyName)) {
535
            if ($passWholeConfig) {
536
                $options = $config;
537
            } else {
538
                $options = isset($config[$keyName . "Options"]) ?
539
                            $config[$keyName . "Options"] :
540
                            array();
541
            }
542
            $this->$keyName = new $$keyName($options);
543
        } else {
544
            $this->$keyName = $$keyName;
545
        }
546
547
        if (!$this->$keyName instanceof $expectedType) {
548
            throw new \InvalidArgumentException(
549
                "$keyName must be a $expectedType"
550
            );
551
        }
552
    }
553
554
    public function getRollbarData($level, $toLog, $context)
555
    {
556
        return $this->dataBuilder->makeData($level, $toLog, $context);
557
    }
558
559
    public function getDataBuilder()
560
    {
561
        return $this->dataBuilder;
562
    }
563
    
564
    public function getLevelFactory()
565
    {
566
        return $this->levelFactory;
567
    }
568
    
569
    public function getSender()
570
    {
571
        return $this->sender;
572
    }
573
574
    public function getScrubber()
575
    {
576
        return $this->scrubber;
577
    }
578
579
    public function getBatched()
580
    {
581
        return $this->batched;
582
    }
583
584
    public function getBatchSize()
585
    {
586
        return $this->batchSize;
587
    }
588
589
    /**
590
     * @param Payload $payload
591
     * @param Level $level
592
     * @param \Exception | \Throwable $toLog
593
     * @param array $context
594
     * @return Payload
595
     */
596
    public function transform($payload, $level, $toLog, $context)
597
    {
598
        if (count($this->custom) > 0) {
599
            $data = $payload->getData();
600
            $custom = $data->getCustom();
601
            $custom = array_merge(array(), $this->custom, (array)$custom);
602
            $data->setCustom($custom);
603
            $payload->setData($data);
604
        }
605
        if (is_null($this->transformer)) {
606
            return $payload;
607
        }
608
        return $this->transformer->transform($payload, $level, $toLog, $context);
609
    }
610
611
    public function getAccessToken()
612
    {
613
        return $this->accessToken;
614
    }
615
616
    public function enabled()
617
    {
618
        return $this->enabled === true;
619
    }
620
    
621
    public function disabled()
622
    {
623
        return !$this->enabled();
624
    }
625
626
    public function getSendMessageTrace()
627
    {
628
        return $this->sendMessageTrace;
629
    }
630
631
    public function checkIgnored($payload, $accessToken, $toLog, $isUncaught)
632
    {
633
        if (isset($this->checkIgnore)) {
634
            try {
635
                if (call_user_func($this->checkIgnore, $isUncaught, $toLog, $payload)) {
636
                    return true;
637
                }
638
            } catch (Exception $exception) {
0 ignored issues
show
Bug introduced by
The type Rollbar\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
639
                // We should log that we are removing the custom checkIgnore
640
                $this->checkIgnore = null;
641
            }
642
        }
643
        
644
        if ($this->payloadLevelTooLow($payload)) {
645
            return true;
646
        }
647
648
        if (!is_null($this->filter)) {
649
            return $this->filter->shouldSend($payload, $accessToken);
650
        }
651
652
        return false;
653
    }
654
655
    public function internalCheckIgnored($level, $toLog)
656
    {
657
        if ($this->shouldSuppress()) {
658
            return true;
659
        }
660
661
        if ($this->levelTooLow($this->levelFactory->fromName($level))) {
662
            return true;
663
        }
664
665
        if ($toLog instanceof ErrorWrapper) {
666
            return $this->shouldIgnoreErrorWrapper($toLog);
667
        }
668
        
669
        if ($toLog instanceof \Exception) {
670
            return $this->shouldIgnoreException($toLog);
671
        }
672
        
673
        return false;
674
    }
675
676
    /**
677
     * Check if the error should be ignored due to `included_errno` config,
678
     * `use_error_reporting` config or `error_sample_rates` config.
679
     *
680
     * @param errno
681
     *
682
     * @return bool
683
     */
684
    public function shouldIgnoreError($errno)
685
    {
686
        if ($this->useErrorReporting && ($errno & error_reporting()) === 0) {
687
            // ignore due to error_reporting level
688
            return true;
689
        }
690
691
        if ($this->includedErrno != -1 && ($errno & $this->includedErrno) != $errno) {
692
            // ignore
693
            return true;
694
        }
695
696
        if (isset($this->errorSampleRates[$errno])) {
697
            // get a float in the range [0, 1)
698
            // mt_rand() is inclusive, so add 1 to mt_randmax
699
            $float_rand = mt_rand() / ($this->mtRandmax + 1);
700
            if ($float_rand > $this->errorSampleRates[$errno]) {
701
                // skip
702
                return true;
703
            }
704
        }
705
        
706
        return false;
707
    }
708
709
    /**
710
     * Check if the error should be ignored due to `included_errno` config,
711
     * `use_error_reporting` config or `error_sample_rates` config.
712
     *
713
     * @param \Rollbar\ErrorWrapper $toLog
714
     *
715
     * @return bool
716
     */
717
    protected function shouldIgnoreErrorWrapper(ErrorWrapper $toLog)
718
    {
719
        return $this->shouldIgnoreError($toLog->errorLevel);
720
    }
721
    
722
    /**
723
     * Check if the exception should be ignored due to configured exception
724
     * sample rates.
725
     *
726
     * @param \Exception $toLog
727
     *
728
     * @return bool
729
     */
730
    protected function shouldIgnoreException(\Exception $toLog)
731
    {
732
        // get a float in the range [0, 1)
733
        // mt_rand() is inclusive, so add 1 to mt_randmax
734
        $floatRand = mt_rand() / ($this->mtRandmax + 1);
735
        if ($floatRand > $this->exceptionSampleRate($toLog)) {
736
            // skip
737
            return true;
738
        }
739
        
740
        return false;
741
    }
742
    
743
    /**
744
     * Calculate what's the chance of logging this exception according to
745
     * exception sampling.
746
     *
747
     * @param \Exception $toLog
748
     *
749
     * @return float
750
     */
751
    public function exceptionSampleRate(\Exception $toLog)
752
    {
753
        $sampleRate = 1.0;
754
        if (count($this->exceptionSampleRates) == 0) {
755
            return $sampleRate;
756
        }
757
        
758
        $exceptionClasses = array();
759
        
760
        $class = get_class($toLog);
761
        while ($class) {
762
            $exceptionClasses []= $class;
763
            $class = get_parent_class($class);
764
        }
765
        $exceptionClasses = array_reverse($exceptionClasses);
766
        
767
        foreach ($exceptionClasses as $exceptionClass) {
768
            if (isset($this->exceptionSampleRates["$exceptionClass"])) {
769
                $sampleRate = $this->exceptionSampleRates["$exceptionClass"];
770
            }
771
        }
772
        
773
        return $sampleRate;
774
    }
775
776
    /**
777
     * @param Payload $payload
778
     * @return bool
779
     */
780
    private function payloadLevelTooLow($payload)
781
    {
782
        return $this->levelTooLow($payload->getData()->getLevel());
783
    }
784
785
    /**
786
     * @param Level $level
787
     * @return bool
788
     */
789
    private function levelTooLow($level)
790
    {
791
        return $level->toInt() < $this->minimumLevel;
792
    }
793
794
    private function shouldSuppress()
795
    {
796
        return error_reporting() === 0 && !$this->reportSuppressed;
797
    }
798
799
    public function send(EncodedPayload $payload, $accessToken)
800
    {
801
        return $this->sender->send($payload, $accessToken);
802
    }
803
804
    public function sendBatch(&$batch, $accessToken)
805
    {
806
        return $this->sender->sendBatch($batch, $accessToken);
807
    }
808
809
    public function wait($accessToken, $max = 0)
810
    {
811
          $this->sender->wait($accessToken, $max);
812
    }
813
814
    public function handleResponse($payload, $response)
815
    {
816
        if (!is_null($this->responseHandler)) {
817
            $this->responseHandler->handleResponse($payload, $response);
818
        }
819
    }
820
}
821