当前位置: 首页>>代码示例>>PHP>>正文


PHP Graph::getInstance方法代码示例

本文整理汇总了PHP中Graph::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::getInstance方法的具体用法?PHP Graph::getInstance怎么用?PHP Graph::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUnprogrammedKeyMissingEnabledUsingConstructor

 public function testUnprogrammedKeyMissingEnabledUsingConstructor()
 {
     $graph = Graph::getInstance(true);
     $nodes = $graph->getNodes();
     $this->assertNotNull($nodes[ord('')]);
     $expected = array('Up' => '8', 'Right' => ' ', 'Down' => 'I', 'Left' => '>');
     $this->assertEquals($expected, $nodes[ord('')]);
 }
开发者ID:shoaibi,项目名称:speed-typing,代码行数:8,代码来源:GraphTest.php

示例2: __construct

 public function __construct($sentence, $enableUnProgrammedKeyForTraversal = false)
 {
     if (!is_string($sentence)) {
         throw new InvalidArgumentException("Sentence should be string");
     }
     if (empty($sentence)) {
         throw new InvalidArgumentException("Sentence should not be empty");
     }
     $this->sentence = $sentence;
     $graph = Graph::getInstance($enableUnProgrammedKeyForTraversal);
     $this->nodes = $graph->getNodes();
     $this->fullPath = array();
 }
开发者ID:shoaibi,项目名称:speed-typing,代码行数:13,代码来源:KeySequenceGenerator.php

示例3: testProcessWithComplicatedStringWithTraversal

 /**
  * @depends testProcessWithComplicatedStringWithSentenceGenerationFromSequence
  */
 public function testProcessWithComplicatedStringWithTraversal()
 {
     $sentence = 'AA qu!c7 br0wn (fox) {jumps} ov:e> a la,zy_[dog].';
     $generator = new KeySequenceGenerator($sentence);
     $generator->process();
     $sequence = $generator->printSequences(true, true);
     $this->assertEquals(2659, strlen($sequence));
     $sequenceTokens = explode(PHP_EOL, $sequence);
     $graph = Graph::getInstance();
     $nodes = $graph->getNodes();
     $node = $nodes[ord($sequenceTokens[0])];
     for ($i = 1; $i < count($sequenceTokens); $i++) {
         if ($sequenceTokens[$i] === KeyPress::ENTER) {
             continue;
         }
         if (in_array($sequenceTokens[$i], array(KeyPress::UP, KeyPress::RIGHT, KeyPress::DOWN, KeyPress::LEFT))) {
             $next = $i + 1;
             $this->assertEquals($node[$sequenceTokens[$i]], $sequenceTokens[$next]);
             $node = $nodes[ord($sequenceTokens[$next])];
         }
     }
 }
开发者ID:shoaibi,项目名称:speed-typing,代码行数:25,代码来源:KeySequenceGeneratorTest.php


注:本文中的Graph::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。