DMS\Filter\Rules\Callback::getInputType PHP Method

getInputType() public method

Figures out which type of input was provided
public getInputType ( ) : string
return string
    public function getInputType()
    {
        switch (true) {
            case $this->callback instanceof Closure:
                return self::CLOSURE_TYPE;
            case is_callable($this->callback, false):
                return self::CALLABLE_TYPE;
            case is_string($this->callback):
                return self::SELF_METHOD_TYPE;
        }
        throw new InvalidCallbackException("The input provided for Callback filter is not supported or the callable not valid.\n            Please refer to the class documentation.");
    }

Usage Example

Beispiel #1
0
 /**
  * @param $input
  * @param $expectedOutput
  * @param $expectException
  *
  * @dataProvider provideInputs
  */
 public function testGetInputType($input, $expectedOutput, $expectException)
 {
     if ($expectException) {
         $this->setExpectedException('DMS\\Filter\\Exception\\InvalidCallbackException');
     }
     $rule = new Callback($input);
     $this->assertEquals($expectedOutput, $rule->getInputType());
 }