Best AspectMock code snippet using or
dual_c_calcs.php
Source:dual_c_calcs.php
...3{4 $dynes = array();5 $aspect_power = array(); //PlanetAspectPower()6 $harmony = array(); //PlanetHarmony()7 $discord = array(); //PlanetDiscord()8 $tot_p = 0; //TotP19 $tot_h = 0; //TotH110 $p1_limit = 10;11 $p2_limit = 10;12 if (($hob[1] == 12) And ($mob[1] == 0))13 {14 $p1_limit = 9;15 }16 if (($hob[2] == 12) And ($mob[2] == 0))17 {18 $p2_limit = 9;19 }20 for ($y = 0; $y <= $p1_limit; $y++)21 {22 for ($x = 0; $x <= $p2_limit; $x++)23 {24 if (($y == 7 Or $y == 8 Or $y == 9) And ($x == 7 Or $x == 8 Or $x == 9))25 {26 // skip this planet and move to the next27 continue;28 }29 else30 {31 // get house of 1st planet32 $yh = floor($house_pos1[$y]);33 if ($y == 10)34 {35 $yh = 10;36 $orb30y = 3;37 $orb45y = 5;38 $orb60y = 7;39 $orb90y = 10;40 $orb180y = 12;41 $pow30y = 3;42 $pow45y = 5;43 $pow60y = 7;44 $pow90y = 10;45 $pow180y = 12;46 }47 else48 {49 // find ORB for 1st planet ($y), dependent upon what house $y is in AND whether it is a Luminary or a planet50 if (($y != 0 And $y != 1) And ($yh == 3 Or $yh == 6 Or $yh == 9 Or $yh == 12))51 {52 $orb30y = 1;53 $orb45y = 3;54 $orb60y = 5;55 $orb90y = 6;56 $orb180y = 8;57 $pow30y = 1;58 $pow45y = 3;59 $pow60y = 5;60 $pow90y = 6;61 $pow180y = 8;62 if ($y == 2)63 {64 $pow30y += 1;65 $pow45y += 1;66 $pow60y += 1;67 $pow90y += 2;68 $pow180y += 3;69 }70 }71 elseif (($y == 0 Or $y == 1) And ($yh == 3 Or $yh == 6 Or $yh == 9 Or $yh == 12))72 {73 $orb30y = 2;74 $orb45y = 4;75 $orb60y = 6;76 $orb90y = 8;77 $orb180y = 11;78 $pow30y = 2;79 $pow45y = 4;80 $pow60y = 6;81 $pow90y = 8;82 $pow180y = 11;83 }84 elseif (($y != 0 And $y != 1) And ($yh == 2 Or $yh == 5 Or $yh == 8 Or $yh == 11))85 {86 $orb30y = 2;87 $orb45y = 4;88 $orb60y = 6;89 $orb90y = 8;90 $orb180y = 10;91 $pow30y = 2;92 $pow45y = 4;93 $pow60y = 6;94 $pow90y = 8;95 $pow180y = 10;96 if ($y == 2)97 {98 $pow30y += 1;99 $pow45y += 1;100 $pow60y += 1;101 $pow90y += 2;102 $pow180y += 3;103 }104 }105 elseif (($y == 0 Or $y == 1) And ($yh == 2 Or $yh == 5 Or $yh == 8 Or $yh == 11))106 {107 $orb30y = 3;108 $orb45y = 5;109 $orb60y = 7;110 $orb90y = 10;111 $orb180y = 13;112 $pow30y = 3;113 $pow45y = 5;114 $pow60y = 7;115 $pow90y = 10;116 $pow180y = 13;117 }118 elseif (($y != 0 And $y != 1) And ($yh == 1 Or $yh == 4 Or $yh == 7 Or $yh == 10))119 {120 $orb30y = 3;121 $orb45y = 5;122 $orb60y = 7;123 $orb90y = 10;124 $orb180y = 12;125 $pow30y = 3;126 $pow45y = 5;127 $pow60y = 7;128 $pow90y = 10;129 $pow180y = 12;130 if ($y == 2)131 {132 $pow30y += 1;133 $pow45y += 1;134 $pow60y += 1;135 $pow90y += 2;136 $pow180y += 3;137 }138 }139 elseif (($y == 0 Or $y == 1) And ($yh == 1 Or $yh == 4 Or $yh == 7 Or $yh == 10))140 {141 $orb30y = 4;142 $orb45y = 6;143 $orb60y = 8;144 $orb90y = 12;145 $orb180y = 15;146 $pow30y = 4;147 $pow45y = 6;148 $pow60y = 8;149 $pow90y = 12;150 $pow180y = 15;151 }152 }153 // get house of 2nd planet154 $xh = floor($house_pos2[$x]);155 if ($x == 10)156 {157 $xh = 10;158 $orb30x = 3;159 $orb45x = 5;160 $orb60x = 7;161 $orb90x = 10;162 $orb180x = 12;163 $pow30x = 3;164 $pow45x = 5;165 $pow60x = 7;166 $pow90x = 10;167 $pow180x = 12;168 }169 else170 {171 // find ORB for 2nd planet ($x), dependent upon what house $x is in AND whether it is a Luminary or a planet172 if (($x != 0 And $x != 1) And ($xh == 3 Or $xh == 6 Or $xh == 9 Or $xh == 12))173 {174 $orb30x = 1;175 $orb45x = 3;176 $orb60x = 5;177 $orb90x = 6;178 $orb180x = 8;179 $pow30x = 1;180 $pow45x = 3;181 $pow60x = 5;182 $pow90x = 6;183 $pow180x = 8;184 if ($x == 2)185 {186 $pow30x += 1;187 $pow45x += 1;188 $pow60x += 1;189 $pow90x += 2;190 $pow180x += 3;191 }192 }193 elseif (($x == 0 Or $x == 1) And ($xh == 3 Or $xh == 6 Or $xh == 9 Or $xh == 12))194 {195 $orb30x = 2;196 $orb45x = 4;197 $orb60x = 6;198 $orb90x = 8;199 $orb180x = 11;200 $pow30x = 2;201 $pow45x = 4;202 $pow60x = 6;203 $pow90x = 8;204 $pow180x = 11;205 }206 elseif (($x != 0 And $x != 1) And ($xh == 2 Or $xh == 5 Or $xh == 8 Or $xh == 11))207 {208 $orb30x = 2;209 $orb45x = 4;210 $orb60x = 6;211 $orb90x = 8;212 $orb180x = 10;213 $pow30x = 2;214 $pow45x = 4;215 $pow60x = 6;216 $pow90x = 8;217 $pow180x = 10;218 if ($x == 2)219 {220 $pow30x += 1;221 $pow45x += 1;222 $pow60x += 1;223 $pow90x += 2;224 $pow180x += 3;225 }226 }227 elseif (($x == 0 Or $x == 1) And ($xh == 2 Or $xh == 5 Or $xh == 8 Or $xh == 11))228 {229 $orb30x = 3;230 $orb45x = 5;231 $orb60x = 7;232 $orb90x = 10;233 $orb180x = 13;234 $pow30x = 3;235 $pow45x = 5;236 $pow60x = 7;237 $pow90x = 10;238 $pow180x = 13;239 }240 elseif (($x != 0 And $x != 1) And ($xh == 1 Or $xh == 4 Or $xh == 7 Or $xh == 10))241 {242 $orb30x = 3;243 $orb45x = 5;244 $orb60x = 7;245 $orb90x = 10;246 $orb180x = 12;247 $pow30x = 3;248 $pow45x = 5;249 $pow60x = 7;250 $pow90x = 10;251 $pow180x = 12;252 if ($x == 2)253 {254 $pow30x += 1;255 $pow45x += 1;256 $pow60x += 1;257 $pow90x += 2;258 $pow180x += 3;259 }260 }261 elseif (($x == 0 Or $x == 1) And ($xh == 1 Or $xh == 4 Or $xh == 7 Or $xh == 10))262 {263 $orb30x = 4;264 $orb45x = 6;265 $orb60x = 8;266 $orb90x = 12;267 $orb180x = 15;268 $pow30x = 4;269 $pow45x = 6;270 $pow60x = 8;271 $pow90x = 12;272 $pow180x = 15;273 }274 }275 }276 $orb30 = $orb30y;277 if ($orb30x >= $orb30y)278 {279 $orb30 = $orb30x;280 }281 $orb45 = $orb45y;282 if ($orb45x >= $orb45y)283 {284 $orb45 = $orb45x;285 }286 $orb60 = $orb60y;287 if ($orb60x >= $orb60y)288 {289 $orb60 = $orb60x;290 }291 $orb90 = $orb90y;292 if ($orb90x >= $orb90y)293 {294 $orb90 = $orb90x;295 }296 $orb180 = $orb180y;297 if ($orb180x >= $orb180y)298 {299 $orb180 = $orb180x;300 }301 $pow30 = $pow30y;302 if ($pow30x >= $pow30y)303 {304 $pow30 = $pow30x;305 }306 $pow45 = $pow45y;307 if ($pow45x >= $pow45y)308 {309 $pow45 = $pow45x;310 }311 $pow60 = $pow60y;312 if ($pow60x >= $pow60y)313 {314 $pow60 = $pow60x;315 }316 $pow90 = $pow90y;317 if ($pow90x >= $pow90y)318 {319 $pow90 = $pow90x;320 }321 $pow180 = $pow180y;322 if ($pow180x >= $pow180y)323 {324 $pow180 = $pow180x;325 }326 // is there an aspect within orb?327 $da = Abs($longitude1[$y] - $longitude2[$x]); //$da means distance apart328 if ($da > 180)329 {330 $da = 360 - $da;331 }332 $q = 1;333 $k = $da;334 if ($k <= $orb180)335 {336 $q = 2;337 $orbxx = $pow180;338 $daxx = $da;339 }340 elseif (($k <= (30 + $orb30)) And ($k >= (30 - $orb30)))341 {342 $q = 8;343 $orbxx = $pow30;344 $daxx = $da - 30;345 }346 elseif (($k <= (45 + $orb45)) And ($k >= (45 - $orb45)))347 {348 $q = 9;349 $orbxx = $pow45;350 $daxx = $da - 45;351 }352 elseif (($k <= (60 + $orb60)) And ($k >= (60 - $orb60)))353 {354 $q = 3;355 $orbxx = $pow60;356 $daxx = $da - 60;357 }358 elseif (($k <= (90 + $orb90)) And ($k >= (90 - $orb90)))359 {360 $q = 4;361 $orbxx = $pow90;362 $daxx = $da - 90;363 }364 // $da is checked here to separate the overlap in the two aspects from 129 - 132 degrees for luminaries365 elseif (($da <= 130) And ($k <= (120 + $orb90)) And ($k >= (120 - $orb90)))366 {367 $q = 5;368 $orbxx = $pow90;369 $daxx = $da - 120;370 }371 elseif (($da > 130) And ($k <= (135 + $orb45)) And ($k >= (135 - $orb45)))372 {373 $q = 10;374 $orbxx = $pow45;375 $daxx = $da - 135;376 }377 elseif (($k <= (150 + $orb30)) And ($k >= (150 - $orb30)))378 {379 $q = 11;380 $orbxx = $pow30;381 $daxx = $da - 150;382 }383 elseif ($k >= (180 - $orb180))384 {385 $q = 6;386 $orbxx = $pow180;387 $daxx = $da - 180;388 }389 if ($q > 1)390 {391 // we have an aspect, so get all the proper numbers392 $dyne_val = $orbxx - Abs($daxx);393 $aspect_power[$y] += $dyne_val;394 //get planetary harmony and discord395 if ($q == 3 Or $q == 5 Or $q == 8)396 {397 $harmony[$y] += $dyne_val;398 }399 if ($q == 4 Or $q == 9 Or $q == 10)400 {401 $discord[$y] += $dyne_val;402 }403 if ($q == 2)404 {405 // check out conjunctions between planets406 if (($y == 0 And $x == 1) Or ($x == 0 And $y == 1))407 {408 // these conjunctions treated as harmonious409 $harmony[$y] += $dyne_val;410 }411 if (($y == 0 And $x == 3) Or ($x == 0 And $y == 3))412 {413 // these conjunctions treated as harmonious414 $harmony[$y] += $dyne_val;415 }416 if (($y == 0 And $x == 5) Or ($x == 0 And $y == 5))417 {418 // these conjunctions treated as harmonious419 $harmony[$y] += ($dyne_val / 2);420 }421 if (($y == 1 And $x == 3) Or ($x == 1 And $y == 3))422 {423 // these conjunctions treated as harmonious424 $harmony[$y] += ($dyne_val / 2);425 }426 if (($y == 4 And $x == 6) Or ($x == 4 And $y == 6))427 {428 // these conjunctions treated as discordant429 $discord[$y] += ($dyne_val / 2);430 }431 if (($y == 4 And $x == 9) Or ($x == 4 And $y == 9))432 {433 // these conjunctions treated as discordant434 $discord[$y] += ($dyne_val / 2);435 }436 if (($y == 6 And $x == 9) Or ($x == 6 And $y == 9))437 {438 // these conjunctions treated as discordant439 $discord[$y] += ($dyne_val / 2);440 }441 if (($y == 6 And $x == 10) Or ($x == 6 And $y == 10))442 {443 // these conjunctions treated as discordant444 $discord[$y] += ($dyne_val / 2);445 }446 if (($y == 9 And $x == 10) Or ($x == 9 And $y == 10))447 {448 // these conjunctions treated as discordant449 $discord[$y] += ($dyne_val / 2);450 }451 }452 if ($q == 6)453 {454 // some opposition aspects treated as discordant455 if (($y == 4 And $x != 5) Or ($x == 4 And $y != 5))456 {457 if (($y == 4 And $x != 10) Or ($x == 4 And $y != 10))458 {459 if (($y == 4 And $x != 3) Or ($x == 4 And $y != 3))460 {461 // these oppositions treated as discordant462 $discord[$y] += $dyne_val;463 }464 }465 }466 if (($y == 6 And $x != 5) Or ($x == 6 And $y != 5))467 {468 if (($y == 6 And $x != 10) Or ($x == 6 And $y != 10))469 {470 if (($y == 6 And $x != 4) Or ($x == 6 And $y != 4))471 {472 // these oppositions treated as discordant473 if ($y == 6 And $x == 6)474 {475 // do not do anything with Saturn opposite Saturn476 }477 else478 {479 $discord[$y] += $dyne_val;480 }481 }482 }483 }484 if (($y == 9 And $x != 5) Or ($x == 9 And $y != 5))485 {486 if (($y == 9 And $x != 10) Or ($x == 9 And $y != 10))487 {488 if (($y == 9 And $x != 4) Or ($x == 9 And $y != 4))489 {490 if (($y == 9 And $x != 6) Or ($x == 9 And $y != 6))491 {492 // these oppositions treated as discordant493 $discord[$y] += $dyne_val;494 }495 }496 }497 }498 if (($y == 0 And $x == 1) Or ($x == 0 And $y == 1))499 {500 // these oppositions treated as harmonious501 $harmony[$y] += ($dyne_val / 2);502 }503 if (($y == 0 And $x == 3) Or ($x == 0 And $y == 3))504 {505 // these oppositions treated as harmonious506 $harmony[$y] += ($dyne_val / 2);507 }508 if (($y == 0 And $x == 10) Or ($x == 0 And $y == 10))509 {510 // these oppositions treated as harmonious511 $harmony[$y] += ($dyne_val / 2);512 }513 if (($y == 1 And $x == 10) Or ($x == 1 And $y == 10))514 {515 // these oppositions treated as harmonious516 $harmony[$y] += ($dyne_val / 2);517 }518 if (($y == 1 And $x == 3) Or ($x == 1 And $y == 3))519 {520 // these oppositions treated as harmonious521 $harmony[$y] += ($dyne_val / 2);522 }523 if (($y == 3 And $x == 5) Or ($x == 3 And $y == 5))524 {525 // these oppositions treated as harmonious526 $harmony[$y] += $dyne_val;527 }528 if (($y == 3 And $x == 10) Or ($x == 3 And $y == 10))529 {530 // these oppositions treated as harmonious531 $harmony[$y] += ($dyne_val / 2);532 }533 if (($y == 5 And $x == 10) Or ($x == 5 And $y == 10))534 {535 // these oppositions treated as harmonious536 $harmony[$y] += ($dyne_val / 2);537 }538 if (($y == 2 And $x == 3) Or ($x == 2 And $y == 3))539 {540 // these oppositions treated as harmonious541 $harmony[$y] += ($dyne_val / 4);542 }543 }544 if ($y == 5 Or $x == 5)545 {546 if (($y == $x) And ($q == 2))547 {548 // ignore Jupiter conjunct Jupiter549 }550 else551 {552 // these treated as harmonious553 $harmony[$y] += ($dyne_val / 2);554 }555 }556 if ($y == 3 Or $x == 3)557 {558 if (($y == 7 Or $y == 8 Or $y == 9 Or $x == 7 Or $x == 8 Or $x == 9) And ($q == 2 Or $q == 6 Or $q == 11))559 {560 // ignore561 }562 else563 {564 // these oppositions treated as harmonious565 $harmony[$y] += ($dyne_val / 4);566 }567 }568 if ($y == 6 Or $x == 6)569 {570 if (($y == $x) And ($q == 2))571 {572 // ignore Saturn conjunct Saturn573 }574 else575 {576 // Saturn aspects treated as discordant577 $discord[$y] += ($dyne_val / 2);578 }579 }580 if ($y == 4 Or $x == 4)581 {582 // Mars aspects treated as discordant583 $discord[$y] += ($dyne_val / 4);584 }585 }586 // now do declinations587 $diff_decl = Abs(Abs($declination1[$y]) - Abs($declination2[$x]));588 if ($diff_decl < 1)589 {590 if (($y != 0 And $y != 1 And $y != 2) And ($yh == 3 Or $yh == 6 Or $yh == 9 Or $yh == 12))591 {592 $orb180y = 8;593 }594 if (($y == 0 Or $y == 1 Or $y == 2) And ($yh == 3 Or $yh == 6 Or $yh == 9 Or $yh == 12))595 {596 $orb180y = 11;597 }598 if (($y != 0 And $y != 1 And $y != 2) And ($yh == 2 Or $yh == 5 Or $yh == 8 Or $yh == 11))599 {600 $orb180y = 10;601 }602 if (($y == 0 Or $y == 1 Or $y == 2) And ($yh == 2 Or $yh == 5 Or $yh == 8 Or $yh == 11))603 {604 $orb180y = 13;605 }606 if (($y != 0 And $y != 1 And $y != 2) And ($yh == 1 Or $yh == 4 Or $yh == 7 Or $yh == 10))607 {608 $orb180y = 12;609 }610 if (($y == 0 Or $y == 1 Or $y == 2) And ($yh == 1 Or $yh == 4 Or $yh == 7 Or $yh == 10))611 {612 $orb180y = 15;613 }614 if (($x != 0 And $x != 1 And $x != 2) And ($xh == 3 Or $xh == 6 Or $xh == 9 Or $xh == 12))615 {616 $orb180x = 8;617 }618 if (($x == 0 Or $x == 1 Or $x == 2) And ($xh == 3 Or $xh == 6 Or $xh == 9 Or $xh == 12))619 {620 $orb180x = 11;621 }622 if (($x != 0 And $x != 1 And $x != 2) And ($xh == 2 Or $xh == 5 Or $xh == 8 Or $xh == 11))623 {624 $orb180x = 10;625 }626 if (($x == 0 Or $x == 1 Or $x == 2) And ($xh == 2 Or $xh == 5 Or $xh == 8 Or $xh == 11))627 {628 $orb180x = 13;629 }630 if (($x != 0 And $x != 1 And $x != 2) And ($xh == 1 Or $xh == 4 Or $xh == 7 Or $xh == 10))631 {632 $orb180x = 12;633 }634 if (($x == 0 Or $x == 1 Or $x == 2) And ($xh == 1 Or $xh == 4 Or $xh == 7 Or $xh == 10))635 {636 $orb180x = 15;637 }638 $orb180 = $orb180y;639 if ($orb180x >= $orb180y)640 {641 $orb180 = $orb180x;642 }643 $decl_power = $orb180 * (1 - $diff_decl);644 $aspect_power[$y] += $decl_power;645 if ($y == 5 Or $x == 5)646 {647 if (($y == $x) And ($q == 2))648 {649 // ignore Jupiter parallel Jupiter650 }651 else652 {653 // these treated as harmonious654 $harmony[$y] += ($decl_power / 2);655 }656 }657 if ($y == 3 Or $x == 3)658 {659 if ($y == 7 Or $y == 8 Or $y == 9 Or $x == 7 Or $x == 8 Or $x == 9)660 {661 // ignore662 }663 else664 {665 // these treated as harmonious666 $harmony[$y] += ($decl_power / 4);667 }668 }669 if ($y == 6 Or $x == 6)670 {671 if (($y == $x) And ($q == 2))672 {673 // ignore Saturn parallel Saturn674 }675 else676 {677 // Saturn aspects treated as discordant678 $discord[$y] += ($decl_power / 2);679 }680 }681 if ($y == 4 Or $x == 4)682 {683 // Mars aspects treated as discordant684 $discord[$y] += ($decl_power / 4);685 }686 }687 }688 }689 for ($y = 0; $y <= $p1_limit; $y++)690 {691 $dynes[0] += $aspect_power[$y];692 $dynes[1] += $harmony[$y] - $discord[$y];693 }694 return $dynes;695}696?>...
calc_dual_dyne_harmony.php
Source:calc_dual_dyne_harmony.php
...11 if (($hob[2] == 12) And ($mob[2] == 0))12 {13 $p2_limit = 9;14 }15 for ($y = 0; $y <= $p1_limit; $y++)16 {17 for ($x = 0; $x <= $p2_limit; $x++)18 {19 $dynes[$y][$x] = 0;20 21 if (($y == 7 Or $y == 8 Or $y == 9) And ($x == 7 Or $x == 8 Or $x == 9))22 {23 // skip this planet and move to the next24 continue;25 }26 else27 {28 // get house of 1st planet29 $yh = floor($house_pos1[$y]);30 if ($y == 10)31 {32 $yh = 10;33 $orb30y = 3;34 $orb45y = 5;35 $orb60y = 7;36 $orb90y = 10;37 $orb180y = 12;38 $pow30y = 3;39 $pow45y = 5;40 $pow60y = 7;41 $pow90y = 10;42 $pow180y = 12;43 }44 else45 {46 // find ORB for 1st planet ($y), dependent upon what house $y is in AND whether it is a Luminary or a planet47 if (($y != 0 And $y != 1) And ($yh == 3 Or $yh == 6 Or $yh == 9 Or $yh == 12))48 {49 $orb30y = 1;50 $orb45y = 3;51 $orb60y = 5;52 $orb90y = 6;53 $orb180y = 8;54 $pow30y = 1;55 $pow45y = 3;56 $pow60y = 5;57 $pow90y = 6;58 $pow180y = 8;59 if ($y == 2)60 {61 $pow30y += 1;62 $pow45y += 1;63 $pow60y += 1;64 $pow90y += 2;65 $pow180y += 3;66 }67 }68 elseif (($y == 0 Or $y == 1) And ($yh == 3 Or $yh == 6 Or $yh == 9 Or $yh == 12))69 {70 $orb30y = 2;71 $orb45y = 4;72 $orb60y = 6;73 $orb90y = 8;74 $orb180y = 11;75 $pow30y = 2;76 $pow45y = 4;77 $pow60y = 6;78 $pow90y = 8;79 $pow180y = 11;80 }81 elseif (($y != 0 And $y != 1) And ($yh == 2 Or $yh == 5 Or $yh == 8 Or $yh == 11))82 {83 $orb30y = 2;84 $orb45y = 4;85 $orb60y = 6;86 $orb90y = 8;87 $orb180y = 10;88 $pow30y = 2;89 $pow45y = 4;90 $pow60y = 6;91 $pow90y = 8;92 $pow180y = 10;93 if ($y == 2)94 {95 $pow30y += 1;96 $pow45y += 1;97 $pow60y += 1;98 $pow90y += 2;99 $pow180y += 3;100 }101 }102 elseif (($y == 0 Or $y == 1) And ($yh == 2 Or $yh == 5 Or $yh == 8 Or $yh == 11))103 {104 $orb30y = 3;105 $orb45y = 5;106 $orb60y = 7;107 $orb90y = 10;108 $orb180y = 13;109 $pow30y = 3;110 $pow45y = 5;111 $pow60y = 7;112 $pow90y = 10;113 $pow180y = 13;114 }115 elseif (($y != 0 And $y != 1) And ($yh == 1 Or $yh == 4 Or $yh == 7 Or $yh == 10))116 {117 $orb30y = 3;118 $orb45y = 5;119 $orb60y = 7;120 $orb90y = 10;121 $orb180y = 12;122 $pow30y = 3;123 $pow45y = 5;124 $pow60y = 7;125 $pow90y = 10;126 $pow180y = 12;127 if ($y == 2)128 {129 $pow30y += 1;130 $pow45y += 1;131 $pow60y += 1;132 $pow90y += 2;133 $pow180y += 3;134 }135 }136 elseif (($y == 0 Or $y == 1) And ($yh == 1 Or $yh == 4 Or $yh == 7 Or $yh == 10))137 {138 $orb30y = 4;139 $orb45y = 6;140 $orb60y = 8;141 $orb90y = 12;142 $orb180y = 15;143 $pow30y = 4;144 $pow45y = 6;145 $pow60y = 8;146 $pow90y = 12;147 $pow180y = 15;148 }149 }150 // get house of 2nd planet151 $xh = floor($house_pos2[$x]);152 if ($x == 10)153 {154 $xh = 10;155 $orb30x = 3;156 $orb45x = 5;157 $orb60x = 7;158 $orb90x = 10;159 $orb180x = 12;160 $pow30x = 3;161 $pow45x = 5;162 $pow60x = 7;163 $pow90x = 10;164 $pow180x = 12;165 }166 else167 {168 // find ORB for 2nd planet ($x), dependent upon what house $x is in AND whether it is a Luminary or a planet169 if (($x != 0 And $x != 1) And ($xh == 3 Or $xh == 6 Or $xh == 9 Or $xh == 12))170 {171 $orb30x = 1;172 $orb45x = 3;173 $orb60x = 5;174 $orb90x = 6;175 $orb180x = 8;176 $pow30x = 1;177 $pow45x = 3;178 $pow60x = 5;179 $pow90x = 6;180 $pow180x = 8;181 if ($x == 2)182 {183 $pow30x += 1;184 $pow45x += 1;185 $pow60x += 1;186 $pow90x += 2;187 $pow180x += 3;188 }189 }190 elseif (($x == 0 Or $x == 1) And ($xh == 3 Or $xh == 6 Or $xh == 9 Or $xh == 12))191 {192 $orb30x = 2;193 $orb45x = 4;194 $orb60x = 6;195 $orb90x = 8;196 $orb180x = 11;197 $pow30x = 2;198 $pow45x = 4;199 $pow60x = 6;200 $pow90x = 8;201 $pow180x = 11;202 }203 elseif (($x != 0 And $x != 1) And ($xh == 2 Or $xh == 5 Or $xh == 8 Or $xh == 11))204 {205 $orb30x = 2;206 $orb45x = 4;207 $orb60x = 6;208 $orb90x = 8;209 $orb180x = 10;210 $pow30x = 2;211 $pow45x = 4;212 $pow60x = 6;213 $pow90x = 8;214 $pow180x = 10;215 if ($x == 2)216 {217 $pow30x += 1;218 $pow45x += 1;219 $pow60x += 1;220 $pow90x += 2;221 $pow180x += 3;222 }223 }224 elseif (($x == 0 Or $x == 1) And ($xh == 2 Or $xh == 5 Or $xh == 8 Or $xh == 11))225 {226 $orb30x = 3;227 $orb45x = 5;228 $orb60x = 7;229 $orb90x = 10;230 $orb180x = 13;231 $pow30x = 3;232 $pow45x = 5;233 $pow60x = 7;234 $pow90x = 10;235 $pow180x = 13;236 }237 elseif (($x != 0 And $x != 1) And ($xh == 1 Or $xh == 4 Or $xh == 7 Or $xh == 10))238 {239 $orb30x = 3;240 $orb45x = 5;241 $orb60x = 7;242 $orb90x = 10;243 $orb180x = 12;244 $pow30x = 3;245 $pow45x = 5;246 $pow60x = 7;247 $pow90x = 10;248 $pow180x = 12;249 if ($x == 2)250 {251 $pow30x += 1;252 $pow45x += 1;253 $pow60x += 1;254 $pow90x += 2;255 $pow180x += 3;256 }257 }258 elseif (($x == 0 Or $x == 1) And ($xh == 1 Or $xh == 4 Or $xh == 7 Or $xh == 10))259 {260 $orb30x = 4;261 $orb45x = 6;262 $orb60x = 8;263 $orb90x = 12;264 $orb180x = 15;265 $pow30x = 4;266 $pow45x = 6;267 $pow60x = 8;268 $pow90x = 12;269 $pow180x = 15;270 }271 }272 }273 $orb30 = $orb30y;274 if ($orb30x >= $orb30y)275 {276 $orb30 = $orb30x;277 }278 $orb45 = $orb45y;279 if ($orb45x >= $orb45y)280 {281 $orb45 = $orb45x;282 }283 $orb60 = $orb60y;284 if ($orb60x >= $orb60y)285 {286 $orb60 = $orb60x;287 }288 $orb90 = $orb90y;289 if ($orb90x >= $orb90y)290 {291 $orb90 = $orb90x;292 }293 $orb180 = $orb180y;294 if ($orb180x >= $orb180y)295 {296 $orb180 = $orb180x;297 }298 $pow30 = $pow30y;299 if ($pow30x >= $pow30y)300 {301 $pow30 = $pow30x;302 }303 $pow45 = $pow45y;304 if ($pow45x >= $pow45y)305 {306 $pow45 = $pow45x;307 }308 $pow60 = $pow60y;309 if ($pow60x >= $pow60y)310 {311 $pow60 = $pow60x;312 }313 $pow90 = $pow90y;314 if ($pow90x >= $pow90y)315 {316 $pow90 = $pow90x;317 }318 $pow180 = $pow180y;319 if ($pow180x >= $pow180y)320 {321 $pow180 = $pow180x;322 }323 // is there an aspect within orb?324 $da = Abs($longitude1[$y] - $longitude2[$x]); //$da means distance apart325 if ($da > 180) { $da = 360 - $da; }326 $q = 1;327 $k = $da;328 if ($k <= $orb180)329 {330 $q = 2;331 $orbxx = $pow180;332 $daxx = $da;333 }334 elseif (($k <= (30 + $orb30)) And ($k >= (30 - $orb30)))335 {336 $q = 8;337 $orbxx = $pow30;338 $daxx = $da - 30;339 }340 elseif (($k <= (45 + $orb45)) And ($k >= (45 - $orb45)))341 {342 $q = 9;343 $orbxx = $pow45;344 $daxx = $da - 45;345 }346 elseif (($k <= (60 + $orb60)) And ($k >= (60 - $orb60)))347 {348 $q = 3;349 $orbxx = $pow60;350 $daxx = $da - 60;351 }352 elseif (($k <= (90 + $orb90)) And ($k >= (90 - $orb90)))353 {354 $q = 4;355 $orbxx = $pow90;356 $daxx = $da - 90;357 }358 // $da is checked here to separate the overlap in the two aspects from 129 - 132 degrees for luminaries359 elseif (($da <= 130) And ($k <= (120 + $orb90)) And ($k >= (120 - $orb90)))360 {361 $q = 5;362 $orbxx = $pow90;363 $daxx = $da - 120;364 }365 elseif (($da > 130) And ($k <= (135 + $orb45)) And ($k >= (135 - $orb45)))366 {367 $q = 10;368 $orbxx = $pow45;369 $daxx = $da - 135;370 }371 elseif (($k <= (150 + $orb30)) And ($k >= (150 - $orb30)))372 {373 $q = 11;374 $orbxx = $pow30;375 $daxx = $da - 150;376 }377 elseif ($k >= (180 - $orb180))378 {379 $q = 6;380 $orbxx = $pow180;381 $daxx = $da - 180;382 }383 if ($q > 1)384 {385 // we have an aspect, so get all the proper numbers386 $dyne_val = $orbxx - Abs($daxx);387 //get planetary harmony and discord388 if ($q == 3 Or $q == 5 Or $q == 8)389 {390 $dynes[$y][$x] += $dyne_val;391 }392 if ($q == 4 Or $q == 9 Or $q == 10)393 {394 $dynes[$y][$x] -= $dyne_val;395 }396 if ($q == 2)397 {398 // check out conjunctions between planets399 if (($y == 0 And $x == 1) Or ($x == 0 And $y == 1))400 {401 // these conjunctions treated as harmonious402 $dynes[$y][$x] += $dyne_val;403 }404 if (($y == 0 And $x == 3) Or ($x == 0 And $y == 3))405 {406 // these conjunctions treated as harmonious407 $dynes[$y][$x] += $dyne_val;408 }409 if (($y == 0 And $x == 5) Or ($x == 0 And $y == 5))410 {411 // these conjunctions treated as harmonious412 $dynes[$y][$x] += ($dyne_val / 2);413 }414 if (($y == 1 And $x == 3) Or ($x == 1 And $y == 3))415 {416 // these conjunctions treated as harmonious417 $dynes[$y][$x] += ($dyne_val / 2);418 }419 if (($y == 4 And $x == 6) Or ($x == 4 And $y == 6))420 {421 // these conjunctions treated as discordant422 $dynes[$y][$x] -= ($dyne_val / 2);423 }424 if (($y == 4 And $x == 9) Or ($x == 4 And $y == 9))425 {426 // these conjunctions treated as discordant427 $dynes[$y][$x] -= ($dyne_val / 2);428 }429 if (($y == 6 And $x == 9) Or ($x == 6 And $y == 9))430 {431 // these conjunctions treated as discordant432 $dynes[$y][$x] -= ($dyne_val / 2);433 }434 if (($y == 6 And $x == 10) Or ($x == 6 And $y == 10))435 {436 // these conjunctions treated as discordant437 $dynes[$y][$x] -= ($dyne_val / 2);438 }439 if (($y == 9 And $x == 10) Or ($x == 9 And $y == 10))440 {441 // these conjunctions treated as discordant442 $dynes[$y][$x] -= ($dyne_val / 2);443 }444 }445 if ($q == 6)446 {447 // some opposition aspects treated as discordant448 if (($y == 4 And $x != 5) Or ($x == 4 And $y != 5))449 {450 if (($y == 4 And $x != 10) Or ($x == 4 And $y != 10))451 {452 if (($y == 4 And $x != 3) Or ($x == 4 And $y != 3))453 {454 // these oppositions treated as discordant455 $dynes[$y][$x] -= $dyne_val;456 }457 }458 }459 if (($y == 6 And $x != 5) Or ($x == 6 And $y != 5))460 {461 if (($y == 6 And $x != 10) Or ($x == 6 And $y != 10))462 {463 if (($y == 6 And $x != 4) Or ($x == 6 And $y != 4))464 {465 // these oppositions treated as discordant466 if ($y == 6 And $x == 6)467 {468 // do not do anything with Saturn opposite Saturn469 }470 else471 {472 $dynes[$y][$x] -= $dyne_val;473 }474 }475 }476 }477 if (($y == 9 And $x != 5) Or ($x == 9 And $y != 5))478 {479 if (($y == 9 And $x != 10) Or ($x == 9 And $y != 10))480 {481 if (($y == 9 And $x != 4) Or ($x == 9 And $y != 4))482 {483 if (($y == 9 And $x != 6) Or ($x == 9 And $y != 6))484 {485 // these oppositions treated as discordant486 $dynes[$y][$x] -= $dyne_val;487 }488 }489 }490 }491 if (($y == 0 And $x == 1) Or ($x == 0 And $y == 1))492 {493 // these oppositions treated as harmonious494 $dynes[$y][$x] += ($dyne_val / 2);495 }496 if (($y == 0 And $x == 3) Or ($x == 0 And $y == 3))497 {498 // these oppositions treated as harmonious499 $dynes[$y][$x] += ($dyne_val / 2);500 }501 if (($y == 0 And $x == 10) Or ($x == 0 And $y == 10))502 {503 // these oppositions treated as harmonious504 $dynes[$y][$x] += ($dyne_val / 2);505 }506 if (($y == 1 And $x == 10) Or ($x == 1 And $y == 10))507 {508 // these oppositions treated as harmonious509 $dynes[$y][$x] += ($dyne_val / 2);510 }511 if (($y == 1 And $x == 3) Or ($x == 1 And $y == 3))512 {513 // these oppositions treated as harmonious514 $dynes[$y][$x] += ($dyne_val / 2);515 }516 if (($y == 3 And $x == 5) Or ($x == 3 And $y == 5))517 {518 // these oppositions treated as harmonious519 $dynes[$y][$x] += $dyne_val;520 }521 if (($y == 3 And $x == 10) Or ($x == 3 And $y == 10))522 {523 // these oppositions treated as harmonious524 $dynes[$y][$x] += ($dyne_val / 2);525 }526 if (($y == 5 And $x == 10) Or ($x == 5 And $y == 10))527 {528 // these oppositions treated as harmonious529 $dynes[$y][$x] += ($dyne_val / 2);530 }531 if (($y == 2 And $x == 3) Or ($x == 2 And $y == 3))532 {533 // these oppositions treated as harmonious534 $dynes[$y][$x] += ($dyne_val / 4);535 }536 }537 if ($y == 5 Or $x == 5)538 {539 if (($y == $x) And ($q == 2))540 {541 // ignore Jupiter conjunct Jupiter542 }543 else544 {545 // these treated as harmonious546 $dynes[$y][$x] += ($dyne_val / 2);547 }548 }549 if ($y == 3 Or $x == 3)550 {551 if (($y == 7 Or $y == 8 Or $y == 9 Or $x == 7 Or $x == 8 Or $x == 9) And ($q == 2 Or $q == 6 Or $q == 11))552 {553 // ignore554 }555 else556 {557 // these oppositions treated as harmonious558 $dynes[$y][$x] += ($dyne_val / 4);559 }560 }561 if ($y == 6 Or $x == 6)562 {563 if (($y == $x) And ($q == 2))564 {565 // ignore Saturn conjunct Saturn566 }567 else568 {569 // Saturn aspects treated as discordant570 $dynes[$y][$x] -= ($dyne_val / 2);571 }572 }573 if ($y == 4 Or $x == 4)574 {575 // Mars aspects treated as discordant576 $dynes[$y][$x] -= ($dyne_val / 4);577 }578 }579 }580 }581 return $dynes;582}583?>...
InstanceManager.php
Source:InstanceManager.php
1<?php2/**3 * Zend Framework (http://framework.zend.com/)4 *5 * @link http://github.com/zendframework/zf2 for the canonical source repository6 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)7 * @license http://framework.zend.com/license/new-bsd New BSD License8 */9namespace Zend\Di;10/**11 * Registry of instantiated objects, their names and the parameters used to build them12 */13class InstanceManager /* implements InstanceManagerInterface */14{15 /**16 * Array of shared instances17 * @var array18 */19 protected $sharedInstances = array();20 /**21 * Array of shared instances with params22 * @var array23 */24 protected $sharedInstancesWithParams = array('hashShort' => array(), 'hashLong' => array());25 /**26 * Array of class aliases27 * @var array key: alias, value: class28 */29 protected $aliases = array();30 /**31 * The template to use for housing configuration information32 * @var array33 */34 protected $configurationTemplate = array(35 /**36 * alias|class => alias|class37 * interface|abstract => alias|class|object38 * name => value39 */40 'parameters' => array(),41 /**42 * injection type => array of ordered method params43 */44 'injections' => array(),45 /**46 * alias|class => bool47 */48 'shared' => true49 );50 /**51 * An array of instance configuration data52 * @var array53 */54 protected $configurations = array();55 /**56 * An array of globally preferred implementations for interfaces/abstracts57 * @var array58 */59 protected $typePreferences = array();60 /**61 * Does this instance manager have this shared instance62 * @param string $classOrAlias63 * @return bool64 */65 public function hasSharedInstance($classOrAlias)66 {67 return isset($this->sharedInstances[$classOrAlias]);68 }69 /**70 * getSharedInstance()71 */72 public function getSharedInstance($classOrAlias)73 {74 return $this->sharedInstances[$classOrAlias];75 }76 /**77 * Add shared instance78 *79 * @param object $instance80 * @param string $classOrAlias81 * @throws Exception\InvalidArgumentException82 */83 public function addSharedInstance($instance, $classOrAlias)84 {85 if (!is_object($instance)) {86 throw new Exception\InvalidArgumentException('This method requires an object to be shared. Class or Alias given: ' . $classOrAlias);87 }88 $this->sharedInstances[$classOrAlias] = $instance;89 }90 /**91 * hasSharedInstanceWithParameters()92 *93 * @param string $classOrAlias94 * @param array $params95 * @param bool $returnFastHashLookupKey96 * @return bool|string97 */98 public function hasSharedInstanceWithParameters($classOrAlias, array $params, $returnFastHashLookupKey = false)99 {100 ksort($params);101 $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params));102 if (isset($this->sharedInstancesWithParams['hashShort'][$hashKey])) {103 $hashValue = $this->createHashForValues($classOrAlias, $params);104 if (isset($this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue])) {105 return ($returnFastHashLookupKey) ? $hashKey . '/' . $hashValue : true;106 }107 }108 return false;109 }110 /**111 * addSharedInstanceWithParameters()112 *113 * @param object $instance114 * @param string $classOrAlias115 * @param array $params116 * @return void117 */118 public function addSharedInstanceWithParameters($instance, $classOrAlias, array $params)119 {120 ksort($params);121 $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params));122 $hashValue = $this->createHashForValues($classOrAlias, $params);123 if (!isset($this->sharedInstancesWithParams[$hashKey])124 || !is_array($this->sharedInstancesWithParams[$hashKey])) {125 $this->sharedInstancesWithParams[$hashKey] = array();126 }127 $this->sharedInstancesWithParams['hashShort'][$hashKey] = true;128 $this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue] = $instance;129 }130 /**131 * Retrieves an instance by its name and the parameters stored at its instantiation132 *133 * @param string $classOrAlias134 * @param array $params135 * @param bool|null $fastHashFromHasLookup136 * @return object|bool false if no instance was found137 */138 public function getSharedInstanceWithParameters($classOrAlias, array $params, $fastHashFromHasLookup = null)139 {140 if ($fastHashFromHasLookup) {141 return $this->sharedInstancesWithParams['hashLong'][$fastHashFromHasLookup];142 }143 ksort($params);144 $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params));145 if (isset($this->sharedInstancesWithParams['hashShort'][$hashKey])) {146 $hashValue = $this->createHashForValues($classOrAlias, $params);147 if (isset($this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue])) {148 return $this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue];149 }150 }151 return false;152 }153 /**154 * Check for an alias155 *156 * @param string $alias157 * @return bool158 */159 public function hasAlias($alias)160 {161 return (isset($this->aliases[$alias]));162 }163 /**164 * Get aliases165 *166 * @return array167 */168 public function getAliases()169 {170 return $this->aliases;171 }172 /**173 * getClassFromAlias()174 *175 * @param string176 * @return string|bool177 * @throws Exception\RuntimeException178 */179 public function getClassFromAlias($alias)180 {181 if (!isset($this->aliases[$alias])) {182 return false;183 }184 $r = 0;185 while (isset($this->aliases[$alias])) {186 $alias = $this->aliases[$alias];187 $r++;188 if ($r > 100) {189 throw new Exception\RuntimeException(190 sprintf('Possible infinite recursion in DI alias! Max recursion of 100 levels reached at alias "%s".', $alias)191 );192 }193 }194 return $alias;195 }196 /**197 * @param string $alias198 * @return string|bool199 * @throws Exception\RuntimeException200 */201 protected function getBaseAlias($alias)202 {203 if (!$this->hasAlias($alias)) {204 return false;205 }206 $lastAlias = false;207 $r = 0;208 while (isset($this->aliases[$alias])) {209 $lastAlias = $alias;210 $alias = $this->aliases[$alias];211 $r++;212 if ($r > 100) {213 throw new Exception\RuntimeException(214 sprintf('Possible infinite recursion in DI alias! Max recursion of 100 levels reached at alias "%s".', $alias)215 );216 }217 }218 return $lastAlias;219 }220 /**221 * Add alias222 *223 * @throws Exception\InvalidArgumentException224 * @param string $alias225 * @param string $class226 * @param array $parameters227 * @return void228 */229 public function addAlias($alias, $class, array $parameters = array())230 {231 if (!preg_match('#^[a-zA-Z0-9-_]+$#', $alias)) {232 throw new Exception\InvalidArgumentException(233 'Aliases must be alphanumeric and can contain dashes and underscores only.'234 );235 }236 $this->aliases[$alias] = $class;237 if ($parameters) {238 $this->setParameters($alias, $parameters);239 }240 }241 /**242 * Check for configuration243 *244 * @param string $aliasOrClass245 * @return bool246 */247 public function hasConfig($aliasOrClass)248 {249 $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass;250 if (!isset($this->configurations[$key])) {251 return false;252 }253 if ($this->configurations[$key] === $this->configurationTemplate) {254 return false;255 }256 return true;257 }258 /**259 * Sets configuration for a single alias/class260 *261 * @param string $aliasOrClass262 * @param array $configuration263 * @param bool $append264 */265 public function setConfig($aliasOrClass, array $configuration, $append = false)266 {267 $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass;268 if (!isset($this->configurations[$key]) || !$append) {269 $this->configurations[$key] = $this->configurationTemplate;270 }271 // Ignore anything but 'parameters' and 'injections'272 $configuration = array(273 'parameters' => isset($configuration['parameters']) ? $configuration['parameters'] : array(),274 'injections' => isset($configuration['injections']) ? $configuration['injections'] : array(),275 'shared' => isset($configuration['shared']) ? $configuration['shared'] : true276 );277 $this->configurations[$key] = array_replace_recursive($this->configurations[$key], $configuration);278 }279 /**280 * Get classes281 *282 * @return array283 */284 public function getClasses()285 {286 $classes = array();287 foreach ($this->configurations as $name => $data) {288 if (strpos($name, 'alias') === 0) continue;289 $classes[] = $name;290 }291 return $classes;292 }293 /**294 * @param string $aliasOrClass295 * @return array296 */297 public function getConfig($aliasOrClass)298 {299 $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass;300 if (isset($this->configurations[$key])) {301 return $this->configurations[$key];302 }303 return $this->configurationTemplate;304 }305 /**306 * setParameters() is a convenience method for:307 * setConfig($type, array('parameters' => array(...)), true);308 *309 * @param string $aliasOrClass Alias or Class310 * @param array $parameters Multi-dim array of parameters and their values311 * @return void312 */313 public function setParameters($aliasOrClass, array $parameters)314 {315 $this->setConfig($aliasOrClass, array('parameters' => $parameters), true);316 }317 /**318 * setInjections() is a convenience method for:319 * setConfig($type, array('injections' => array(...)), true);320 *321 * @param string $aliasOrClass Alias or Class322 * @param array $injections Multi-dim array of methods and their parameters323 * @return void324 */325 public function setInjections($aliasOrClass, array $injections)326 {327 $this->setConfig($aliasOrClass, array('injections' => $injections), true);328 }329 /**330 * Set shared331 *332 * @param string $aliasOrClass333 * @param bool $isShared334 * @return void335 */336 public function setShared($aliasOrClass, $isShared)337 {338 $this->setConfig($aliasOrClass, array('shared' => (bool) $isShared), true);339 }340 /**341 * Check for type preferences342 *343 * @param string $interfaceOrAbstract344 * @return bool345 */346 public function hasTypePreferences($interfaceOrAbstract)347 {348 $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;349 return (isset($this->typePreferences[$key]) && $this->typePreferences[$key]);350 }351 /**352 * Set type preference353 *354 * @param string $interfaceOrAbstract355 * @param array $preferredImplementations356 * @return InstanceManager357 */358 public function setTypePreference($interfaceOrAbstract, array $preferredImplementations)359 {360 $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;361 foreach ($preferredImplementations as $preferredImplementation) {362 $this->addTypePreference($key, $preferredImplementation);363 }364 return $this;365 }366 /**367 * Get type preferences368 *369 * @param string $interfaceOrAbstract370 * @return array371 */372 public function getTypePreferences($interfaceOrAbstract)373 {374 $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;375 if (isset($this->typePreferences[$key])) {376 return $this->typePreferences[$key];377 }378 return array();379 }380 /**381 * Unset type preferences382 *383 * @param string $interfaceOrAbstract384 * @return void385 */386 public function unsetTypePreferences($interfaceOrAbstract)387 {388 $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;389 unset($this->typePreferences[$key]);390 }391 /**392 * Adds a type preference. A type preference is a redirection to a preferred alias or type when an abstract type393 * $interfaceOrAbstract is requested394 *395 * @param string $interfaceOrAbstract396 * @param string $preferredImplementation397 * @return self398 */399 public function addTypePreference($interfaceOrAbstract, $preferredImplementation)400 {401 $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;402 if (!isset($this->typePreferences[$key])) {403 $this->typePreferences[$key] = array();404 }405 $this->typePreferences[$key][] = $preferredImplementation;406 return $this;407 }408 /**409 * Removes a previously set type preference410 *411 * @param string $interfaceOrAbstract412 * @param string $preferredType413 * @return bool|self414 */415 public function removeTypePreference($interfaceOrAbstract, $preferredType)416 {417 $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;418 if (!isset($this->typePreferences[$key]) || !in_array($preferredType, $this->typePreferences[$key])) {419 return false;420 }421 unset($this->typePreferences[$key][array_search($key, $this->typePreferences)]);422 return $this;423 }424 /**425 * @param string $classOrAlias426 * @param string[] $paramKeys427 * @return string428 */429 protected function createHashForKeys($classOrAlias, $paramKeys)430 {431 return $classOrAlias . ':' . implode('|', $paramKeys);432 }433 /**434 * @param string $classOrAlias435 * @param array $paramValues436 * @return string437 */438 protected function createHashForValues($classOrAlias, $paramValues)439 {440 $hashValue = '';441 foreach ($paramValues as $param) {442 switch (gettype($param)) {443 case 'object':444 $hashValue .= spl_object_hash($param) . '|';445 break;446 case 'integer':447 case 'string':448 case 'boolean':449 case 'NULL':450 case 'double':451 $hashValue .= $param . '|';452 break;453 case 'array':454 $hashValue .= 'Array|';455 break;...
dual_c_mrs.php
Source:dual_c_mrs.php
1<?php2Function GetMutualReceptions($longitude1, $longitude2)3{4 $num_MRs = 0;5 for ($y = 0; $y <= 9; $y++)6 {7 $sy = floor($longitude1[$y] / 30) + 1;8 for ($x = 0; $x <= 9; $x++)9 {10 // get sign of each planet11 $sx = floor($longitude2[$x] / 30) + 1;12 // look for all mutual receptions13 if ($y == 0 And ($sy == 4 Or $sy == 2) And $x == 1 And ($sx == 1 Or $sx == 5))14 $num_MRs++;15 if ($y == 0 And ($sy == 3 Or $sy == 11) And $x == 7 And ($sx == 1 Or $sx == 5))16 $num_MRs++;17 if ($y == 0 And ($sy == 9 Or $sy == 12) And $x == 8 And ($sx == 1 Or $sx == 5))18 $num_MRs++;19 if ($y == 0 And ($sy == 5 Or $sy == 8) And $x == 9 And ($sx == 1 Or $sx == 5))20 $num_MRs++;21 if ($y == 0 And ($sy == 3 Or $sy == 6 Or $sy == 11) And $x == 2 And ($sx == 1 Or $sx == 5))22 $num_MRs++;23 if ($y == 0 And ($sy == 2 Or $sy == 7 Or $sy == 12) And $x == 3 And ($sx == 1 Or $sx == 5))24 $num_MRs++;25 if ($y == 0 And ($sy == 1 Or $sy == 8 Or $sy == 10) And $x == 4 And ($sx == 1 Or $sx == 5))26 $num_MRs++;...
functions.php
Source:functions.php
...43 if (!is_array($array) || !$array) {44 $resolve();45 return;46 }47 foreach ($array as $promiseOrValue) {48 $cancellationQueue->enqueue($promiseOrValue);49 resolve($promiseOrValue)50 ->done($resolve, $reject, $notify);51 }52 }, $reject, $notify);53 }, $cancellationQueue);54}55function any($promisesOrValues)56{57 return some($promisesOrValues, 1)58 ->then(function ($val) {59 return \array_shift($val);60 });61}62function some($promisesOrValues, $howMany)63{64 $cancellationQueue = new CancellationQueue();65 $cancellationQueue->enqueue($promisesOrValues);66 return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $howMany, $cancellationQueue) {67 resolve($promisesOrValues)68 ->done(function ($array) use ($howMany, $cancellationQueue, $resolve, $reject, $notify) {69 if (!\is_array($array) || $howMany < 1) {70 $resolve([]);71 return;72 }73 $len = \count($array);74 if ($len < $howMany) {75 throw new Exception\LengthException(76 \sprintf(77 'Input array must contain at least %d item%s but contains only %s item%s.',78 $howMany,79 1 === $howMany ? '' : 's',80 $len,81 1 === $len ? '' : 's'82 )83 );84 }85 $toResolve = $howMany;86 $toReject = ($len - $toResolve) + 1;87 $values = [];88 $reasons = [];89 foreach ($array as $i => $promiseOrValue) {90 $fulfiller = function ($val) use ($i, &$values, &$toResolve, $toReject, $resolve) {91 if ($toResolve < 1 || $toReject < 1) {92 return;93 }94 $values[$i] = $val;95 if (0 === --$toResolve) {96 $resolve($values);97 }98 };99 $rejecter = function ($reason) use ($i, &$reasons, &$toReject, $toResolve, $reject) {100 if ($toResolve < 1 || $toReject < 1) {101 return;102 }103 $reasons[$i] = $reason;104 if (0 === --$toReject) {105 $reject($reasons);106 }107 };108 $cancellationQueue->enqueue($promiseOrValue);109 resolve($promiseOrValue)110 ->done($fulfiller, $rejecter, $notify);111 }112 }, $reject, $notify);113 }, $cancellationQueue);114}115function map($promisesOrValues, callable $mapFunc)116{117 $cancellationQueue = new CancellationQueue();118 $cancellationQueue->enqueue($promisesOrValues);119 return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $mapFunc, $cancellationQueue) {120 resolve($promisesOrValues)121 ->done(function ($array) use ($mapFunc, $cancellationQueue, $resolve, $reject, $notify) {122 if (!\is_array($array) || !$array) {123 $resolve([]);124 return;125 }126 $toResolve = \count($array);127 $values = [];128 foreach ($array as $i => $promiseOrValue) {129 $cancellationQueue->enqueue($promiseOrValue);130 $values[$i] = null;131 resolve($promiseOrValue)132 ->then($mapFunc)133 ->done(134 function ($mapped) use ($i, &$values, &$toResolve, $resolve) {135 $values[$i] = $mapped;136 if (0 === --$toResolve) {137 $resolve($values);138 }139 },140 $reject,141 $notify142 );...
or
Using AI Code Generation
1$mock = \AspectMock\Kernel::getInstance();2$mock->init([3]);4$mock->loadFile(__DIR__ . '/../src/AspectMock/Kernel.php');5$mock->loadFile(__DIR__ . '/../src/AspectMock/Proxy/Verifier.php');6$mock = \AspectMock\Kernel::getInstance();7$mock->init([8]);9$mock->loadFile(__DIR__ . '/../src/AspectMock/Kernel.php');10$mock->loadFile(__DIR__ . '/../src/AspectMock/Proxy/Verifier.php');11$mock = \AspectMock\Kernel::getInstance();12$mock->init([13]);14$mock->loadFile(__DIR__ . '/../src/AspectMock/Kernel.php');15$mock->loadFile(__DIR__ . '/../src/AspectMock/Proxy/Verifier.php');16$mock = \AspectMock\Kernel::getInstance();17$mock->init([18]);19$mock->loadFile(__DIR__ . '/../src/AspectMock/Kernel.php');20$mock->loadFile(__DIR__ . '/../src/AspectMock/Proxy/Verifier.php');21$mock = \AspectMock\Kernel::getInstance();22$mock->init([
or
Using AI Code Generation
1{2 public function login($username, $password)3 {4 if ($username == 'admin' && $password == 'admin') {5 return true;6 }7 return false;8 }9}10{11 protected $tester;12 protected function _before()13 {14 }15 protected function _after()16 {17 }18 public function testLogin()19 {20 $user = new User();21 $this->assertTrue($user->login('admin', 'admin'));22 $this->assertFalse($user->login('admin', 'admin1'));23 }24}25{26 public function login($username, $password)27 {28 if ($username == 'admin' && $password == 'admin') {29 return true;30 }31 return false;32 }33}34{35 protected $tester;36 protected function _before()37 {38 }39 protected function _after()40 {41 }42 public function testLogin()43 {44 $user = new User();45 $this->assertTrue($user->login('admin', 'admin'));46 $this->assertFalse($user->login('admin', 'admin1'));47 }48}
or
Using AI Code Generation
1use AspectMock\Test as test;2{3 public function testMethod()4 {5 return 'testMethod';6 }7}8use AspectMock\Test as test;9{10 public function testMethod()11 {12 return 'testMethod';13 }14}15use AspectMock\Test as test;16{17 public function testMethod()18 {19 return 'testMethod';20 }21}22use AspectMock\Test as test;23{24 public function testMethod()25 {26 return 'testMethod';27 }28}29use AspectMock\Test as test;30{31 public function testMethod()32 {33 return 'testMethod';34 }35}36use AspectMock\Test as test;37{38 public function testMethod()39 {40 return 'testMethod';41 }42}43use AspectMock\Test as test;44{45 public function testMethod()46 {47 return 'testMethod';48 }49}50use AspectMock\Test as test;51{52 public function testMethod()53 {54 return 'testMethod';55 }56}57use AspectMock\Test as test;58{59 public function testMethod()60 {61 return 'testMethod';62 }63}64use AspectMock\Test as test;65{66 public function testMethod()67 {68 return 'testMethod';69 }70}
or
Using AI Code Generation
1{2 public function getFullName()3 {4 return 'Davert';5 }6}7{8 public function testGetFullName()9 {10 $user = new User();11 $this->assertEquals('Davert', $user->getFullName());12 }13}14{15 public function testGetFullName()16 {17 $user = new User();18 $this->assertEquals('Davert', $user->getFullName());19 }20}21{22 public function testGetFullName()23 {24 $user = new User();25 $this->assertEquals('Davert', $user->getFullName());26 }27}28{29 public function testGetFullName()30 {31 $user = new User();32 $this->assertEquals('Davert', $user->getFullName());33 }34}35{36 public function testGetFullName()37 {38 $user = new User();39 $this->assertEquals('Davert', $user->getFullName());40 }41}42{43 public function testGetFullName()44 {45 $user = new User();46 $this->assertEquals('Davert', $user->getFullName());47 }48}49{50 public function testGetFullName()51 {52 $user = new User();53 $this->assertEquals('Davert', $user->getFullName());54 }55}56{57 public function testGetFullName()58 {59 $user = new User();60 $this->assertEquals('Davert', $user->getFullName());61 }62}63{64 public function testGetFullName()65 {66 $user = new User();67 $this->assertEquals('Davert', $user->getFullName());68 }69}70{
or
Using AI Code Generation
1use AspectMock\Test as test;2{3 public function testGetUser()4 {5 $user = test::double('User', ['get' => 'davert']);6 $this->assertEquals('davert', $user->get());7 }8}9use AspectMock\Test as test;10{11 public function testGetUser()12 {13 $user = test::double('User', ['get' => 'davert']);14 $this->assertEquals('davert', $user->get());15 }16}17use AspectMock\Test as test;18{19 public function testGetUser()20 {21 $user = test::double('User', ['get' => 'davert']);22 $this->assertEquals('davert', $user->get());23 }24}25use AspectMock\Test as test;26{27 public function testGetUser()28 {29 $user = test::double('User', ['get' => 'davert']);30 $this->assertEquals('davert', $user->get());31 }32}33use AspectMock\Test as test;34{35 public function testGetUser()36 {37 $user = test::double('User', ['get' => 'davert']);38 $this->assertEquals('davert', $user->get());39 }40}41use AspectMock\Test as test;42{43 public function testGetUser()44 {45 $user = test::double('User', ['get' => 'davert']);46 $this->assertEquals('davert
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!