PHP Classes

File: client/delete-unique_number

Recommend this page to a friend!
  Classes of nvb   PHP Unique Number Repository   client/delete-unique_number   Download  
File: client/delete-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: 5 years ago
Size: 935 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> <number>' . PHP_EOL;

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

   
throwExceptionIfInvalidNumberOfValuesWasProvided($values, 4);

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

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

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

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