本文整理汇总了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('')]);
}
示例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();
}
示例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])];
}
}
}