-
Notifications
You must be signed in to change notification settings - Fork 7
Github Angola Users #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guimar86
wants to merge
5
commits into
codingdojoangola:desafios
Choose a base branch
from
guimar86:desafios
base: desafios
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7719013
Add files via upload
guimar86 65b8b81
Desafio relativo a api do GitHub, Renato Martins
guimar86 93bbe03
AgeCalculator
guimar86 1d709e7
Test wit curl features
guimar86 824a1c2
Challenge partially completed. Need phpUnit Test
guimar86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
|
|
||
| <?php | ||
|
|
||
| /** | ||
| * @author Renato Martins | ||
| * Date: 09/09/2017 | ||
| * Time: 21:00 | ||
| */ | ||
| class AgeCalculator | ||
| { | ||
|
|
||
| /** | ||
| * Funcao usada para calcular | ||
| * a idade com base no ano de nascimento | ||
| * @param $yearBirth | ||
| * @return false|string | ||
| */ | ||
| function getAge($yearBirth) | ||
| { | ||
|
|
||
|
|
||
| /* | ||
| * Verificar que o parametro de entrada foi providenciado não é igual a null | ||
| */ | ||
| if (!$yearBirth) { | ||
|
|
||
| trigger_error("Parametro de entrada \"Ano de nascimento \" nao foi inserido ", E_USER_ERROR); | ||
| return null; | ||
| } | ||
| //verificar que o parametro de entrada é numerico. | ||
| else if (!is_numeric($yearBirth)) { | ||
| trigger_error("Parametro de entrada não é numérico", E_USER_ERROR); | ||
| return null; | ||
| } | ||
| //verificar que o parametro de entrada tem 4 caracteres. | ||
| else if(strlen($yearBirth)!=4){ | ||
| trigger_error("Parametro de entrada deve ter 4 digitos",E_USER_ERROR); | ||
| return null; | ||
| } | ||
| else{ | ||
|
|
||
| /* | ||
| * O format ("o") permite que a data retorne somente o ano da data actual. | ||
| * http://php.net/manual/en/function.date.php | ||
| */ | ||
| $thisYear = date("o"); | ||
|
|
||
| $esteAno=3; | ||
| // a subtracao do ano de nascimento | ||
| $toReturn = $thisYear - $yearBirth; | ||
|
|
||
| return $toReturn; | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * User: Renato Martins | ||
| * Date: 12/09/2017 | ||
| * Time: 21:13 | ||
| */ | ||
| class GitHubAngola | ||
| { | ||
|
|
||
|
|
||
| /** | ||
| * Função usada para ler o endpoint do gitHub | ||
| * e obter todos utilizadores em Angola | ||
| * =====AUTENTICACAO EM FALTA==== | ||
| * @return array | ||
| */ | ||
| function getGitHubAngolanUsers() | ||
| { | ||
|
|
||
| $toReturn = array(); | ||
| $github_url = 'https://api.github.com/search/users?q=location:Luanda/Angola'; | ||
| $github_json = file_get_contents($github_url); | ||
| $github_array = json_decode($github_json, true); | ||
|
|
||
|
|
||
| if (!empty($github_array)) { | ||
|
|
||
| foreach ($github_array['data'] as $names) { | ||
|
|
||
| array_push($toReturn, ['total_count']['incomplete_results']['items']['login']); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| return $toReturn; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Função usada para ler o endpoint do rest api do github | ||
| * e devolver a lista de utilizadores na localizcao solicitada. | ||
| * ==== AUTENTICACAO EM FALTA ==== | ||
| * @param $location | ||
| * @return array | ||
| */ | ||
| function getGitHubUserByLocation($location) | ||
| { | ||
|
|
||
| $toReturn = array(); | ||
| $github_url = 'https://api.github.com/search/users?q=location:' . $location; | ||
| $github_json = file_get_contents($github_url); | ||
| $github_array = json_decode($github_json, true); | ||
|
|
||
| if (!empty($github_array)) { | ||
|
|
||
| foreach ($github_array['data'] as $names) { | ||
|
|
||
| array_push($toReturn, ['total_count']['incomplete_results']['items']['login']); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| return $toReturn; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @author Renato Martins | ||
| * Date: 09/09/2017 | ||
| * Time: 21:00 | ||
| */ | ||
| class MinhaCalculadora | ||
| { | ||
|
|
||
| /** | ||
| * Funcao usada para calcular | ||
| * a idade com base no ano de nascimento | ||
| * @param $yearBirth | ||
| * @return false|string | ||
| */ | ||
| function getAge($yearBirth) | ||
| { | ||
|
|
||
|
|
||
| /* | ||
| * Verificar que o parametro de entrada foi providenciado não é igual a null | ||
| */ | ||
| if (!$yearBirth) { | ||
|
|
||
| trigger_error("Parametro de entrada \"Ano de nascimento \" nao foi inserido ", E_USER_ERROR); | ||
| return null; | ||
| } | ||
| //verificar que o parametro de entrada é numerico. | ||
| else if (!is_numeric($yearBirth)) { | ||
| trigger_error("Parametro de entrada não é numérico", E_USER_ERROR); | ||
| return null; | ||
| } | ||
| //verificar que o parametro de entrada tem 4 caracteres. | ||
| else if(strlen($yearBirth)!=4){ | ||
| trigger_error("Parametro de entrada deve ter 4 digitos",E_USER_ERROR); | ||
| return null; | ||
| } | ||
| else{ | ||
|
|
||
| /* | ||
| * O format ("o") permite que a data retorne somente o ano da data actual. | ||
| * http://php.net/manual/en/function.date.php | ||
| */ | ||
| $thisYear = date("o"); | ||
|
|
||
| // a subtracao do ano de nascimento | ||
| $toReturn = $thisYear - $yearBirth; | ||
|
|
||
| return $toReturn; | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| <?php | ||
| require('AgeCalculator.php'); | ||
| ?> | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Coding Dojo Angola</title> | ||
|
|
||
| <style type="text/css"> | ||
|
|
||
| * { | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
|
|
||
| #header { | ||
|
|
||
| width: 100%; | ||
| margin: 0; | ||
| height: 50px; | ||
| padding: 5px 10px; | ||
| font-family: 'Palatino Linotype'; | ||
| background-color: #000; | ||
| color: #fff; | ||
| } | ||
|
|
||
| #content { | ||
|
|
||
| margin: 0 auto; | ||
| width: 960px; | ||
| padding: 5px; | ||
| font-family: "Trebuchet MS"; | ||
|
|
||
| } | ||
|
|
||
| form p { | ||
|
|
||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
|
|
||
| </style> | ||
|
|
||
| </head> | ||
| <body> | ||
|
|
||
| <div id="header"> | ||
|
|
||
| <h1>Coding Dojo Angola</h1> | ||
| </div> | ||
|
|
||
| <div id="content"> | ||
|
|
||
| <h1>Calculo da idade</h1> | ||
|
|
||
| <form action="index.php" method="post"> | ||
|
|
||
| <p>Insira o seu <b>ano de nascimento</b><input name="inputAge" type="number"/></p> | ||
|
|
||
| <p> | ||
| <input type="submit" name="submit" value="Submit"/> | ||
| </p> | ||
| </form> | ||
|
|
||
|
|
||
| <?php | ||
| $calculator; | ||
|
|
||
| if (isset($_POST['submit'])) { | ||
|
|
||
|
|
||
| $userAge = $_POST['inputAge']; | ||
|
|
||
| $calculator = new AgeCalculator; | ||
| //new comment | ||
| echo("Voce tem " . $calculator->getAge($userAge) . " ano(s) de idade"); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| ?> | ||
| </div> | ||
|
|
||
| </body> | ||
| </html> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referente ao teste, a classe não deve contar html. O html pode estar por exemplo numa página
/app/github/index.php. Porque nessa classe dentro detestsdeve ser feito o teste usando PHPUnitThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guimar86 falta ajustes para o teste passar no StyleCI.
Dá uma olhada na analise do StyleCI para entender onde ajustar..