PHP Classes

File: tests/apps/prime.php

Recommend this page to a friend!
  Classes of Cesar D. Rodas  >  PHP JSON API Server  >  tests/apps/prime.php  >  Download  
File: tests/apps/prime.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP JSON API Server
Handle REST API requests with functions in scripts
Author: By
Last change:
Date: 4 years ago
Size: 821 bytes
 

Contents

Class file image Download
<?php

/**
 * @API("is_prime")
 *
 * The "bulk" calculation is done in a @initRequest, in this tests
 * it makes no difference but it coves the following scenarios:
 *
 * 1. Imagine we have 5 calls to `is_prime`, and the datasource is a DB
 * - It's much faster to query `IN`
 * - Having a single db query is faster (instead of 5)
 * 2. The @initRequest handler passes datas back to the `is_prime` through the server instance
 */
function is_prime_service(Array $args, $server)
{
    return
$server['is_prime'][$args['q']];
}

/**
 * @API("is_prime_2")
 * @API("is_prime3")
 *
 * Same as is_prime but the data exchange between @initRequest
 * and the service is done throught the args
 */
function is_prime_service_2(Array $args, $server)
{
    return
$args['result'];
}

For more information send a message to info at phpclasses dot org.