Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Sprawdzenie klasy
minolone
post
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 24
Dołączył: 21.06.2008

Ostrzeżenie: (0%)
-----


Witam.
Prosze was o sprawdzenie klasy oraz wyrzucenie mi wszystkich błędów co jest nie tak jak być powinno.
Jest nie skończona ale wszytsko działa tak jak chciałem.
  1. <?php
  2.  
  3. print_r($_POST);
  4.  
  5. class AirConditioning {
  6.  
  7. const HOME = 20;
  8. const HOME_ROOF = 0.2;
  9. const COMPANY = 10;
  10. const COMPANY_PERCENT = 0.1;
  11. const COMPANY_ROOF = 0.1;
  12. const PEOPLE = 0.1;
  13.  
  14. private $people;
  15. //public $window;
  16. private $roof;
  17.  
  18. public function __construct($room, $height, $area, $people, $window, $roof) {
  19. $this->room = $room;
  20. $this->height = $height;
  21. $this->area = $area;
  22. if(!empty($window)) $this->window = $window;
  23. if(!empty($people)) $this->people = $people;
  24. if(!empty($roof)) $this->roof = $roof;
  25. }
  26.  
  27. public function check() {
  28. if($this->room == 0) {
  29. return $this->home($this->height, $this->area);
  30. }
  31. if($this->room == 1) {
  32. return $this->company($this->height, $this->area);
  33. }
  34. }
  35.  
  36. public function home($height, $area) {
  37. $count = $height*$area/self::HOME;
  38.  
  39. if($this->roof == 1) {
  40. $roof = self::HOME_ROOF;
  41. }
  42.  
  43. if($this->people > 0) {
  44. $people = $this->people($this->people);
  45. }
  46.  
  47. if(isset($roof) AND $roof > 0) {
  48. $count = $count+$count*$roof;
  49. }
  50.  
  51. if(isset($people) AND $people > 0) {
  52. $count = $count+$people;
  53. }
  54.  
  55. return $count;
  56. }
  57.  
  58. public function company($height, $area) {
  59. $count = $height*$area;
  60. $count = $count/self::COMPANY;
  61. $add = self::COMPANY_PERCENT;
  62.  
  63. if($this->roof == 1) {
  64. $add += self::COMPANY_ROOF;
  65. }
  66.  
  67. if($this->people > 0) {
  68. $people = $this->people($this->people);
  69. }
  70.  
  71. if(isset($roof) AND $roof > 0) {
  72. $count = $count+$count*$roof;
  73. }
  74.  
  75. if(isset($people) AND $people > 0) {
  76. $count = $count+$people;
  77. }
  78.  
  79. return $count;
  80. }
  81.  
  82. public function people($people) {
  83. $people = $people*self::PEOPLE;
  84. return $people;
  85. }
  86.  
  87. }
  88.  
  89. ?>




Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
rocktech.pl
post
Post #2





Grupa: Zarejestrowani
Postów: 587
Pomógł: 131
Dołączył: 8.02.2010

Ostrzeżenie: (0%)
-----


Witam.

Trochę szczegółów, komentarze, przykłady użycia poprosimy.

Na ten moment PHP_CodeSniffer (IMG:style_emoticons/default/smile.gif)

  1. phpcs AirConditioning.class.php
  2.  
  3. FILE: AirConditioning.class.php
  4. --------------------------------------------------------------------------------
  5. FOUND 25 ERROR(S) AND 3 WARNING(S) AFFECTING 22 LINE(S)
  6. --------------------------------------------------------------------------------
  7. 2 | ERROR | Missing file doc comment
  8. 5 | ERROR | Missing class doc comment
  9. 5 | ERROR | Opening brace of a class must be on the line after the
  10. | | definition
  11. 14 | ERROR | Private member variable "people" must be prefixed with an
  12. | | underscore
  13. 16 | ERROR | Private member variable "roof" must be prefixed with an
  14. | | underscore
  15. 18 | ERROR | You must use "/**" style comments for a function comment
  16. 18 | ERROR | Opening brace should be on a new line
  17. 22 | WARNING | Inline control structures are discouraged
  18. 23 | WARNING | Inline control structures are discouraged
  19. 24 | WARNING | Inline control structures are discouraged
  20. 27 | ERROR | Missing function doc comment
  21. 27 | ERROR | Opening brace should be on a new line
  22. 28 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  23. 31 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  24. 36 | ERROR | Missing function doc comment
  25. 36 | ERROR | Opening brace should be on a new line
  26. 39 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  27. 43 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  28. 47 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  29. 51 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  30. 58 | ERROR | Missing function doc comment
  31. 58 | ERROR | Opening brace should be on a new line
  32. 63 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  33. 67 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  34. 71 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  35. 75 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"
  36. 82 | ERROR | Missing function doc comment
  37. 82 | ERROR | Opening brace should be on a new line
  38. --------------------------------------------------------------------------------


Ten post edytował rocktech.pl 11.01.2012, 15:10:23
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.10.2025 - 01:31