コード例 #1
0
ファイル: Pick.php プロジェクト: fleporcq/wordswar
 /**
  * Construit la pioche
  * @param Configuration $configuration
  */
 public function __construct(Configuration $configuration)
 {
     $configurationArray = $configuration->toArray();
     foreach ($configurationArray['letters'] as $letter => $data) {
         for ($i = 0; $i < $data['count']; $i++) {
             $this->push(new LetterTile($letter, $data['score']));
         }
     }
 }
コード例 #2
0
ファイル: Dictionary.php プロジェクト: fleporcq/wordswar
 /**
  * Construit un nouveau dictionnaire
  * @param Configuration $configuration La configuration globale de l'application
  * @param Language $language La langue du dictionnaire
  * @throws InvalidArgumentException
  * @throws LoadFileException
  */
 public function __construct(Configuration $configuration, Language $language)
 {
     if ($configuration == NULL) {
         throw new InvalidArgumentException('$configuration arg cannot be null');
     }
     if ($language == NULL) {
         throw new InvalidArgumentException('$language arg cannot be null');
     }
     $filepath = $configuration->get('dictionaries:path') . DIRECTORY_SEPARATOR . $language . '.txt';
     if (!is_readable($filepath)) {
         throw new LoadFileException('Cannot read the file ' . $filepath);
     }
     $this->language = $language;
     $this->content = file_get_contents($filepath);
 }
コード例 #3
0
ファイル: Configuration.php プロジェクト: fleporcq/wordswar
 /**
  * Construit un objet de configuration
  * @param type $filename
  * @throws InvalidArgumentException
  * @throws LoadFileException
  */
 public function __construct($filename)
 {
     if ($filename == NULL || !is_string($filename)) {
         throw new InvalidArgumentException('$filename arg cannot be null and must be a string');
     }
     if (!is_readable($filename)) {
         throw new LoadFileException('Cannot read the file ' . $filename);
     }
     $this->filename = $filename;
     $values = Yaml::parse(file_get_contents($filename));
     if (array_key_exists('extends', $values)) {
         $extendsFilename = dirname($filename) . DIRECTORY_SEPARATOR . $values['extends'];
         if (!is_readable($extendsFilename)) {
             throw new LoadFileException('Cannot read the file ' . $extendsFilename);
         }
         $extends = new Configuration($extendsFilename);
         $values = array_replace_recursive($extends->toArray(), $values);
     }
     $this->values = $values;
 }