Class princessBride

Some fun displaying one of the subplots of the movie Princess Bride as a PHP class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

class princessBride {
   
    private $me;
    private $attacker;
   
    /*public function princessBride($me, $attacker = NULL){
        Slated for deprecation as of PHP 5.0
    }*/
   
    public function __construct($me, $attacker){
        $this->me = $me;
        $this->attacker = $attacker;
        $this->sixFingeredMan($this->me, $this->attacker);
    }
   
    private function sixFingeredMan($me, $attacker){
        if(is_object($me)){
            if($this->sixFingers($me) == TRUE){
                if($attacker['name'] ==  'Inigo Montoya' && $attacker['greeting'] == 'You killed my father'){
                    $this->makeOffers($me->dataBank['common_desires']);
                }
            }else{
                return 'You must have me mistaken for someone else';
            }
        }else{
            return 'already dead';
        }
    }
   
    private function prepareToDie($isDead){
        if($isDead == FALSE){
            return 'safe';
        }else{
            die();
        }
    }
   
    private function sixFingers($person_to_check){
        if($person_to_check->rightHand['fingers'] > 5){
            return TRUE;
        }else{
            return FALSE;
        }
    }
   
    private function makeOffers($offers){
        switch(strtolower($offers)){
            case 'Fame':
                $this->prepareToDie(FALSE);
                break;
            case 'Fortune':
                $this->prepareToDie(FALSE);
                break;
            case 'Anything your heart desires':
                $this->prepareToDie(FALSE);
                break;
            case 'I want my father back':
            default:
                $this->prepareToDie(TRUE);
                break;
        }
    }

}

?>