<?php

namespace OnlyBits\Inputs;

use OnlyBits\Connectors\ConnectInterface;
use OnlyBits\Connectors\Wire;

class TwoStateButton implements InputInterface, ConnectInterface
{
    /**
     * Button state 1.
     * @var mixed
     */
    private $state1;

    /**
     * Button state 2.
     * @var mixed
     */
    private $state2;

    /**
     * Button's current state.
     * @var mixed
     */
    private $current_state;

    /**
     * The value outputted by the button.
     * @var mixed
     */
    private $output;

    /**
     * Constructor. The state 1 should be default state.
     *
     * @param mixed $state1 Button state 1
     * @param mixed $state2 Button state 2
     */
    public function __construct($state1, $state2)
    {
        $this->state1 = $state1;
        $this->state2 = $state2;

        $this->current_state = $state1;
        $this->output = $state1;
    }

    /**
     * {@inheritdoc}
     */
    public function trigger()
    {
        $this->current_state = ($this->current_state == $state1) ? $state2 : $state1;

        $this->output = $this->current_state;
    }

    /**
     * {@inheritdoc}
     */
    public function connect(Wire $wire, $pin = null)
    {
        $wire->setValue($this->output);

        return $wire;
    }
}

<?php

namespace OnlyBits\Inputs;

use OnlyBits\Connectors\ConnectInterface;
use OnlyBits\Connectors\Wire;

class TwoStateButton implements InputInterface, ConnectInterface
{
    /**
     * Button state 1.
     * @var mixed
     */
    private $state1;

    /**
     * Button state 2.
     * @var mixed
     */
    private $state2;

    /**
     * Button's current state.
     * @var mixed
     */
    private $current_state;

    /**
     * The value outputted by the button.
     * @var mixed
     */
    private $output;

    /**
     * Constructor. The state 1 should be default state.
     *
     * @param mixed $state1 Button state 1
     * @param mixed $state2 Button state 2
     */
    public function __construct($state1, $state2)
    {
        $this->state1 = $state1;
        $this->state2 = $state2;

        $this->current_state = $state1;
        $this->output = $state1;
    }

    /**
     * {@inheritdoc}
     */
    public function trigger()
    {
        $this->current_state = ($this->current_state == $this->state1) ? $this->state2 : $this->state1;

        $this->output = $this->current_state;
    }

    /**
     * {@inheritdoc}
     */
    public function connect(Wire $wire, $pin = null)
    {
        $wire->setValue($this->output);
    }
}

Fix bug on variable names. Remove return value from connect() because objects are passed by reference.
Fix bug on variable names. Remove return value from connect() because objects are passed by reference.