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
std::vector<int> NumbersValidator::getNegatives(const std::vector<int> & numbers) const { | |
return VectorUtils::filter(numbers, [](int number) { return number < 0; }); | |
} |
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
<?php | |
$elements = array(1, 2, 3); | |
// array_map | |
// (PHP 4 >= 4.0.6, PHP 5) | |
$mappedElements = array_map( | |
function($element) { | |
return 2 * $element; | |
}, |
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
#include <boost/algorithm/string.hpp> | |
#include <boost/algorithm/string/join.hpp> | |
#include <boost/algorithm/string/regex.hpp> | |
#include <boost/regex.hpp> | |
std::vector<std::string> StringUtils::split( | |
const std::string & str, | |
const std::vector<std::string> & delimiters) { | |
std::vector<std::string> tokens; |
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
#include <regex> | |
#include <sstream> | |
std::vector<std::string> StringUtils::split( | |
const std::string & str, | |
const std::vector<std::string> & delimiters) { | |
std::regex rgx(join(escapeStrings(delimiters), "|")); | |
std::sregex_token_iterator |
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
#include <gmock/gmock.h> | |
#include <vector> | |
#include "../code/StringUtils.h" | |
using namespace ::testing; | |
TEST(StringUtils, CanEscapeOneString) { | |
EXPECT_THAT(StringUtils::escapeString("*"), Eq("\\*")); | |
EXPECT_THAT(StringUtils::escapeString("\\"), Eq("\\\\")); |
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
<?php | |
class SendingFormByEmailAndRedirecting | |
{ | |
private $form; | |
private $email; | |
private $formRedirection; | |
function __construct( | |
FormEmail $email, |
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
<?php | |
class SendingFormByEmailAndRedirectingTest extends PHPUnit_Framework_TestCase | |
{ | |
private $form; | |
private $formRedirection; | |
private $email; | |
private $sendAndRedirectAction; | |
private $WHATEVER_FIELDS; |
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
<?php | |
$action = | |
Action::sendingByEmail() | |
->formIn("empresas") | |
->to("[email protected]") | |
->build(); | |
$action->execute(); |
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
<?php | |
class EmailAndRedirectService | |
{ | |
private $redirection; | |
private $emailService; | |
function __construct( | |
FormEmailService $emailService, | |
Redirection $redirection |
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
<?php | |
$service = | |
EmailAndRedirectServiceBuilder::aServiceToSendByEmail() | |
->aFormOnPage("empresas") | |
->to("[email protected]") | |
->build(); | |
$service->sendAndRedirect(new Form($_POST)); |