Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Rx\Operator; use Rx\Disposable\SerialDisposable; use Rx\ObservableInterf..

Decoded Output download

<?php

namespace Rx\Operator;

use Rx\Disposable\SerialDisposable;
use Rx\ObservableInterface;
use Rx\Observer\CallbackObserver;
use Rx\ObserverInterface;
use Rx\SchedulerInterface;

class DefaultIfEmptyOperator implements OperatorInterface
{
    /** @var  ObservableInterface */
    private $observable;

    /** @var bool */
    private $passThrough = false;

    public function __construct(ObservableInterface $observable)
    {
        $this->observable = $observable;
    }

    /**
     * @param \Rx\ObservableInterface $observable
     * @param \Rx\ObserverInterface $observer
     * @param \Rx\SchedulerInterface $scheduler
     * @return \Rx\DisposableInterface
     */
    public function __invoke(ObservableInterface $observable, ObserverInterface $observer, SchedulerInterface $scheduler = null)
    {
        $disposable = new SerialDisposable();
        $cbObserver = new CallbackObserver(
            function ($x) use ($observer) {
                $this->passThrough = true;
                $observer->onNext($x);
            },
            [$observer, 'onError'],
            function () use ($observer, $disposable, $scheduler) {
                if (!$this->passThrough) {
                    $disposable->setDisposable($this->observable->subscribe($observer, $scheduler));
                    return;
                }

                $observer->onCompleted();
            }
        );

        $subscription = $observable->subscribe($cbObserver, $scheduler);

        $disposable->setDisposable($subscription);

        return $disposable;
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Rx\Operator;

use Rx\Disposable\SerialDisposable;
use Rx\ObservableInterface;
use Rx\Observer\CallbackObserver;
use Rx\ObserverInterface;
use Rx\SchedulerInterface;

class DefaultIfEmptyOperator implements OperatorInterface
{
    /** @var  ObservableInterface */
    private $observable;

    /** @var bool */
    private $passThrough = false;

    public function __construct(ObservableInterface $observable)
    {
        $this->observable = $observable;
    }

    /**
     * @param \Rx\ObservableInterface $observable
     * @param \Rx\ObserverInterface $observer
     * @param \Rx\SchedulerInterface $scheduler
     * @return \Rx\DisposableInterface
     */
    public function __invoke(ObservableInterface $observable, ObserverInterface $observer, SchedulerInterface $scheduler = null)
    {
        $disposable = new SerialDisposable();
        $cbObserver = new CallbackObserver(
            function ($x) use ($observer) {
                $this->passThrough = true;
                $observer->onNext($x);
            },
            [$observer, 'onError'],
            function () use ($observer, $disposable, $scheduler) {
                if (!$this->passThrough) {
                    $disposable->setDisposable($this->observable->subscribe($observer, $scheduler));
                    return;
                }

                $observer->onCompleted();
            }
        );

        $subscription = $observable->subscribe($cbObserver, $scheduler);

        $disposable->setDisposable($subscription);

        return $disposable;
    }
}

Function Calls

None

Variables

None

Stats

MD5 bd51f8a39d32c32feeca271fec81f9e0
Eval Count 0
Decode Time 73 ms