PHP Classes

File: client/create-unique_number

Recommend this page to a friend!
  Classes of nvb   PHP Unique Number Repository   client/create-unique_number   Download  
File: client/create-unique_number
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Unique Number Repository
Maintain repositories of unique numbers via an API
Author: By
Last change:
Date: 4 years ago
Size: 844 bytes
 

Contents

Class file image Download
#!/usr/bin/env php
<?php

require_once __DIR__ . '/../bootstrap/client.php';

$usage = 'usage: ' . PHP_EOL .
   
' ' . basename(__FILE__) . ' <host> <applicant name> <repository name>' . PHP_EOL;

execute(function () use ($baseUrl, $command, $values) {

   
throwExceptionIfInvalidNumberOfValuesWasProvided($values, 3);

    list(
$host, $applicantName, $repositoryName) = extractValues($values);

   
throwExceptionIfValueIsInvalid($host, 'host');
   
throwExceptionIfValueIsInvalid($applicantName, 'applicant name');
   
throwExceptionIfValueIsInvalid($repositoryName, 'repository name');

   
$data = array(
       
'applicant_name' => $applicantName
   
);
   
$url = $baseUrl . '/' . $repositoryName;
   
$lines = $command->post($host, $url, $data);

    foreach (
$lines as $line) {
        echo
$line . PHP_EOL;
    }
},
$usage);