Prepare the number validation request

@param int    $number
@param string $callback

@return mixed
482841
public function validate($number, $callback = null, $account = null)
    {
        if (! starts_with($number, '2547')) {
            throw new InvalidArgumentException('The subscriber number must start with 2547');
        }

        $time = Carbon::now()->format('YmdHis');
        $configs = (new ConfigurationRepository)->useAccount($account);

        $shortCode = $configs->getAccountKey('lnmo.shortcode');
        $passkey   = $configs->getAccountKey('lnmo.passkey');
        $callback  = $configs->getAccountKey('lnmo.callback');

        $defaultCallback = $configs->getAccountKey('id_validation_callback');
        $initiator = $configs->getAccountKey('initiator');

        $body = [
            'Initiator'         => $initiator,
            'BusinessShortCode' => $shortCode,
            'Password'          => $this->getPassword($shortCode, $passkey, $time),
            'Timestamp'         => $time,
            'TransactionType'   => 'CheckIdentity',
            'PhoneNumber'       => $number,
            'CallBackURL'       => $callback ?: $defaultCallback,
            'TransactionDesc'   => ' '
        ];

        try {
            $response = $this->makeRequest(
                $body,
                Core::instance()->getEndpoint(MPESA_ID_CHECK, $account),
                $account
            );

            return json_decode($response->getBody());
        } catch (RequestException $exception) {
            return json_decode($exception->getResponse()->getBody());
        }
    }
536115
public function each(callable $callback, $count = 1000)
    {
        return $this->chunk($count, function ($results) use ($callback) {
            foreach ($results as $key => $value) {
                if ($callback($value, $key) === false) {
                    return false;
                }
            }
        });
    }
277585
protected function validOrderNumber($number = null)
    {
        $number = (isset($number)) ? $number : $this->Ref;

        $existing = Estimate::get()
            ->filter(
                [
                    "ClassName" => self::class,
                    "Ref" => $number
                ]
            )->first();

        return !($existing);
    }
400736
private function isValidCallback($callback)
    {
        // For security purposes, we don't want to call anything that isn't
        // an object callback
        if (is_string($callback)) {
            return false;
        }

        if (is_array($callback)) {
            $target = array_shift($callback);
            if (! is_object($target)) {
                return false;
            }
        }

        // Object callback -- always okay
        return true;
    }
1289316
private function callFunction($callback, $data)
    {
        $exp = explode('@', $callback);

        if (method_exists($instance = new $exp[0](), $exp[1])) {
            return call_user_func_array([$instance, $exp[1]], [$data]);
        }
    }
318446
public function get($number)
    {
        if (ArrayOperations::checkNull([$number])) {
            throw
            new PlivoValidationException(
                'number is mandatory');
        }

        $response = $this->client->fetch(
            $this->uri . $number .'/',
            []
        );

        return new Number(
            $this->client, $response->getContent(),
            $this->pathParams['authId']);
    }
484405
public function jsonp($input, $callback)
    {
        return $this
            ->withHeader('Content-Type', 'application/javascript')
            ->write(sprintf('%s(%s);', $callback, json_encode($input)));
    }
1026010
public function setNumber($number)
    {
      if(!is_string($number) || strlen(trim($number)) == 0)
        throw new InvalidArgumentException(__METHOD__ . '; Invalid number, must be a non empty string');

      $this->number = $number;
    }
660900
private function generateCallback(Closure $callback): Closure
    {
        return function ($match) use ($callback) {
            if ($match[1] == '[' && $match[6] == ']') {
                return substr($match[0], 1, -1);
            }

            $content = isset($match[5]) ? $match[5] : null;
            $atts = isset($match[3]) ? $this->parseAttributes($match[3]) : [];

            return $callback($match[2], $content, $atts);
        };
    }
959961
public function setPatch($number)
    {
        if (!Validator::isNumber($number)) {
            throw new InvalidNumberException($number);
        }

        $this->patch = intval($number);

        return $this;
    }
1166204
public function setNumber($number)
    {
        if (!is_string($number) && !is_null($number)) {
            throw new \InvalidArgumentException(__CLASS__ . ' ' . __METHOD__ . ': Not a string');
        }

        $this->number = $number;

        return $this;
    }
311294
public function add_validation_rule(callable $callback) {
        if ($this->mode == self::MODE_COMPLETE) {
            $this->_form->addFormRule($callback);
        }
    }
1068543
protected function callClassBasedExtension( $callback, $parameters )
	{
		if ( Str::contains( $callback, '@' ) )
			list( $class, $method ) = explode( '@', $callback );
		else
			list( $class, $method ) = [$callback, 'validate'];

		return call_user_func_array( [BindingBuilder::resolveBinding( $class ), $method], $parameters );
	}
130680
public static function callback($key = null, $callback)
    {
        // Get parameters for callback
        $callbackParams = func_get_args();
        unset($callbackParams[0], $callbackParams[1]);
        $callbackParams = array_values($callbackParams);

        // Get key if no key is given
        if (is_null($key)) {
            if (is_string($callback)) {
                $key = $callback;
            } elseif (is_array($callback)) {
                $keyArr = [];
                foreach ($callback as $k => $v) {
                    if (is_string($v)) {
                        $keyArr[] = $v;
                    } elseif (is_object($v)) {
                        $keyArr[] = get_class($v);
                    }
                }

                $key = implode('', $keyArr);
                if (count($keyArr) > 1) {
                    $method = array_pop($keyArr);
                    $key    = implode('/', $keyArr);
                    $key    .= '::' . $method;
                }

                unset($keyArr, $method);
            } elseif (is_object($callback) && $callback instanceof \Closure) {
                $key = 'closure';
            }
            $key = 'callback: ' . $key;
        }

        // Set default return value
        $returnValue = true;

        // Set error handler, to convert errors to exceptions
        set_error_handler(function ($errno, $errstr, $errfile, $errline, array $errcontext) {
            throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
        });

        try {
            // Start output buffer to capture any output
            ob_start();

            // Start profiler
            self::start($key);

            // Execute callback, and get result
            $callbackResult = call_user_func_array($callback, $callbackParams);

            // Stop profiler
            self::stop($key);

            // Get and clean output buffer
            $callbackOutput = ob_get_clean();
        } catch (\ErrorException $callbackException) {
            // Stop and clean output buffer
            ob_end_clean();

            // Show error message
            self::output('Invalid callback sent to Timer::callback: ' . str_replace('callback: ', '', $key));

            // Clear the item from the collection
            unset(self::$collection[$key]);

            // Clear callback result and output
            unset($callbackResult, $callbackOutput);

            // Set return value to false
            $returnValue = false;
        }

        // Restore error handler
        restore_error_handler();

        // Return result, output or true
        return (isset($callbackResult) ? $callbackResult : (!empty($callbackOutput) ? $callbackOutput : $returnValue));
    }
213098
public function countBy($callback = null)
    {
        if (is_null($callback)) {
            $callback = function ($value) {
                return $value;
            };
        }

        return new static($this->groupBy($callback)->map(function ($value) {
            return $value->count();
        }));
    }
409737
public static function create(Closure $callback = null, $request = [])
    {
        return (is_callable($callback)) ?
            $callback(new static(Security::create(), $request)) :
            new static(Security::create(), $request);
    }
754581
public function after($number, Closure $closure)
    {
        $hash = spl_object_hash((object) $closure);

        if (isset ($this->delayed[$hash]))
        {
            $closure = $this->delayed[$hash];

            return $closure();
        }

        $this->delayed[$hash] = function() use($number, $closure)
        {
            static $tries = 0;

            $tries += 1;

            if ($tries === $number)
            {
                return $closure();
            }
        };
    }