public static function getInstance()
 {
     if (self::$theInstance == null) {
         self::$theInstance = new PositionService();
     }
     return self::$theInstance;
 }
<?php

/*
Copyright: All contributers to the Umple Project
This file is made available subject to the open source license found at:
http://umple.org/license
*/
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'addPosition':
            require_once "PositionService.php";
            PositionService::getInstance()->setPositionJSON($_POST['positionJSON']);
            $result = PositionService::getInstance()->getLatestResult();
            echo $result;
            break;
    }
} else {
    echo <<<_OUT
\t\t<!DOCTYPE html>
        <html>
                <head>
\t\t\t\t\t<script type="text/javascript" src="addposition.js"></script>
\t\t\t\t\t<link rel="stylesheet" href="usecase.css" />
                </head>
                <body>
                    <div class="mainForm">
\t\t\t\t\t\t<label for="positionName">Enter an position name:</label>
\t\t\t\t\t\t\t\t<input type="text" id="positionName"></input>
\t\t\t\t\t\t<label for="positionDescriptiom">Enter an position description:</label>
\t\t\t\t\t\t\t\t<input type="text" id="positionDescription"></input>
\t\t\t\t\t\t<button id="addPosition" onclick="addPosition()">add</button>
/*
Copyright: All contributers to the Umple Project
This file is made available subject to the open source license found at:
http://umple.org/license
*/
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'loadAllElections':
            require_once "ElectionService.php";
            $allElections = ElectionService::getInstance()->getElections();
            echo $allElections;
            break;
        case 'loadAllPositions':
            require_once "PositionService.php";
            $allPositions = PositionService::getInstance()->getPositions();
            echo $allPositions;
            break;
        case 'addElectionForPosition':
            require_once "ElectionForPositionService.php";
            $first = true;
            $result = '';
            foreach ($_POST as $json) {
                if (!$first) {
                    ElectionForPositionService::getInstance()->setEfpJSON($json);
                    $result = $result . ElectionForPositionService::getInstance()->getLatestResult();
                } else {
                    $first = false;
                }
            }
            echo $result;