DataSift\Storyplayer\OsLib::getHostAdapter PHP Method

getHostAdapter() public static method

public static getHostAdapter ( StoryTeller $st, $osName )
$st DataSift\Storyplayer\PlayerLib\StoryTeller
    public static function getHostAdapter($st, $osName)
    {
        // Make sure that osName is capitalised correctly
        $osNameFixed = array();
        foreach (explode("_", $osName) as $part) {
            $osNameFixed[] = ucfirst(strtolower($part));
        }
        $osName = implode("_", $osNameFixed);
        // what are we looking for?
        $className = 'DataSift\\Storyplayer\\OsLib\\' . $osName;
        // does it exist?
        if (!class_exists($className)) {
            throw new E5xx_ActionFailed(__METHOD__, "cannot find class '{$className}' for host OS '{$osName}'");
        }
        // create the adapter
        $adapter = new $className($st);
        // all done
        return $adapter;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param  string $filename
  * @return object
  */
 public function getFileDetails($filename)
 {
     // what are we doing?
     $log = usingLog()->startAction("get details for '{$filename}' on host '{$this->args[0]}'");
     // make sure we have valid host details
     $hostDetails = $this->getHostDetails();
     // get an object to talk to this host
     $host = OsLib::getHostAdapter($this->st, $hostDetails->osName);
     // get the details
     $details = $host->getFileDetails($hostDetails, $filename);
     // all done
     $log->endAction();
     return $details;
 }
All Usage Examples Of DataSift\Storyplayer\OsLib::getHostAdapter