build() 공개 메소드

Load a engines.json file and parse it into the platforms data array
public build ( array $engineData, array $json, string $engineName ) : Engine
$engineData array
$json array
$engineName string
리턴 Browscap\Data\Engine
예제 #1
0
 /**
  * tests the creating of an engine factory
  *
  * @group data
  * @group sourcetest
  */
 public function testBuild()
 {
     $engineData = array('abc' => 'def');
     $json = array();
     $engineName = 'Test';
     self::assertInstanceOf('\\Browscap\\Data\\Engine', $this->object->build($engineData, $json, $engineName));
 }
예제 #2
0
 /**
  * Load a engines.json file and parse it into the platforms data array
  *
  * @param string $src Name of the file
  *
  * @throws \RuntimeException             if the file does not exist or has invalid JSON
  * @return \Browscap\Data\DataCollection
  */
 public function addEnginesFile($src)
 {
     $json = $this->loadFile($src);
     if (!isset($json['engines'])) {
         throw new \UnexpectedValueException('required "engines" structure is missing');
     }
     $engineFactory = new Factory\EngineFactory();
     foreach (array_keys($json['engines']) as $engineName) {
         $engineData = $json['engines'][$engineName];
         if (!isset($engineData['properties']) && !isset($engineData['inherits'])) {
             throw new \UnexpectedValueException('required attibute "properties" is missing');
         }
         $this->engines[$engineName] = $engineFactory->build($engineData, $json, $engineName);
     }
     $this->divisionsHaveBeenSorted = false;
     return $this;
 }